diff options
Diffstat (limited to 'luni')
4 files changed, 23 insertions, 7 deletions
diff --git a/luni/src/main/java/java/nio/Buffer.java b/luni/src/main/java/java/nio/Buffer.java index c0ba368..bc152ef 100644 --- a/luni/src/main/java/java/nio/Buffer.java +++ b/luni/src/main/java/java/nio/Buffer.java @@ -303,7 +303,7 @@ public abstract class Buffer { */ void limitImpl(int newLimit) { if (newLimit < 0 || newLimit > capacity) { - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Bad limit (capacity " + capacity + "): " + newLimit); } limit = newLimit; @@ -355,7 +355,7 @@ public abstract class Buffer { void positionImpl(int newPosition) { if (newPosition < 0 || newPosition > limit) { - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Bad position (limit " + limit + "): " + newPosition); } position = newPosition; @@ -383,7 +383,7 @@ public abstract class Buffer { */ public final Buffer reset() { if (mark == UNSET_MARK) { - throw new InvalidMarkException(); + throw new InvalidMarkException("Mark not set"); } position = mark; return this; diff --git a/luni/src/main/java/java/nio/DatagramChannelImpl.java b/luni/src/main/java/java/nio/DatagramChannelImpl.java index 7874af6..a626857 100644 --- a/luni/src/main/java/java/nio/DatagramChannelImpl.java +++ b/luni/src/main/java/java/nio/DatagramChannelImpl.java @@ -262,7 +262,9 @@ class DatagramChannelImpl extends DatagramChannel implements FileDescriptorChann begin(); int oldPosition = source.position(); sendCount = IoBridge.sendto(fd, source, 0, isa.getAddress(), isa.getPort()); - source.position(oldPosition + sendCount); + if (sendCount > 0) { + source.position(oldPosition + sendCount); + } } finally { end(sendCount >= 0); } @@ -353,7 +355,9 @@ class DatagramChannelImpl extends DatagramChannel implements FileDescriptorChann } int writeCount = writeImpl(src); - src.position(src.position() + writeCount); + if (writeCount > 0) { + src.position(src.position() + writeCount); + } return writeCount; } diff --git a/luni/src/main/java/java/nio/InvalidMarkException.java b/luni/src/main/java/java/nio/InvalidMarkException.java index cb1050e..349cf3a 100644 --- a/luni/src/main/java/java/nio/InvalidMarkException.java +++ b/luni/src/main/java/java/nio/InvalidMarkException.java @@ -29,4 +29,12 @@ public class InvalidMarkException extends IllegalStateException { */ public InvalidMarkException() { } + + /** + * Constructs an {@code InvalidMarkException} with the given detail message. + * @hide + */ + public InvalidMarkException(String detailMessage) { + super(detailMessage); + } } diff --git a/luni/src/main/java/java/nio/SocketChannelImpl.java b/luni/src/main/java/java/nio/SocketChannelImpl.java index c659299..9f8c690 100644 --- a/luni/src/main/java/java/nio/SocketChannelImpl.java +++ b/luni/src/main/java/java/nio/SocketChannelImpl.java @@ -298,7 +298,9 @@ class SocketChannelImpl extends SocketChannel implements FileDescriptorChannel { begin(); } readCount = IoBridge.recvfrom(true, fd, dst, 0, null, false); - dst.position(dst.position() + readCount); + if (readCount > 0) { + dst.position(dst.position() + readCount); + } } finally { if (isBlocking()) { end(readCount > 0); @@ -360,7 +362,9 @@ class SocketChannelImpl extends SocketChannel implements FileDescriptorChannel { begin(); } writeCount = IoBridge.sendto(fd, src, 0, null, 0); - src.position(src.position() + writeCount); + if (writeCount > 0) { + src.position(src.position() + writeCount); + } } finally { if (isBlocking()) { end(writeCount >= 0); |