diff --git a/classpath/java/nio/channels/SocketChannel.java b/classpath/java/nio/channels/SocketChannel.java index 01eab5283f..6c4738385a 100644 --- a/classpath/java/nio/channels/SocketChannel.java +++ b/classpath/java/nio/channels/SocketChannel.java @@ -58,7 +58,9 @@ public class SocketChannel extends SelectableChannel natThrowWriteError(socket); } int w = natWrite(socket, b.array(), b.arrayOffset() + b.position(), b.remaining()); - b.position(b.position() + w); + if (w > 0) { + b.position(b.position() + w); + } return w; }