summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-08-08 23:42:50 (EDT)
committerCaspar De Groot2010-08-08 23:42:50 (EDT)
commitc921e9d978fafc12bded6b46192847ac555d0d34 (patch)
treecb6a92cface5d6ceb6ad8de0018e38395517c021
parent59c91fbed63f9cbf097fe7ea8b02558e8a4b1787 (diff)
downloadcdo-c921e9d978fafc12bded6b46192847ac555d0d34.zip
cdo-c921e9d978fafc12bded6b46192847ac555d0d34.tar.gz
cdo-c921e9d978fafc12bded6b46192847ac555d0d34.tar.bz2
[322102] Buffer.startGetting does not always handle remote socket closure gracefully
https://bugs.eclipse.org/bugs/show_bug.cgi?id=322102
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java28
2 files changed, 18 insertions, 12 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
index 1e738d4..1e20f0a 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/SignalTest.java
@@ -116,7 +116,7 @@ public class SignalTest extends AbstractProtocolTest
@Override
protected boolean successful()
{
- return lifecycle.isActive();
+ return !lifecycle.isActive();
}
}.assertNoTimeOut();
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java
index 63e7279..a470d0e 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java
@@ -151,12 +151,7 @@ public class Buffer implements InternalBuffer
if (state == BufferState.READING_HEADER)
{
- int num = socketChannel.read(byteBuffer);
- if (num == -1)
- {
- throw new ClosedChannelException();
- }
-
+ readChannel(socketChannel, byteBuffer);
if (byteBuffer.hasRemaining())
{
return null;
@@ -178,11 +173,7 @@ public class Buffer implements InternalBuffer
state = BufferState.READING_BODY;
}
- if (socketChannel.read(byteBuffer) == -1)
- {
- throw new ClosedChannelException();
- }
-
+ readChannel(socketChannel, byteBuffer);
if (byteBuffer.hasRemaining())
{
return null;
@@ -407,4 +398,19 @@ public class Buffer implements InternalBuffer
release();
}
+
+ private static void readChannel(SocketChannel socketChannel, ByteBuffer buffer) throws ClosedChannelException
+ {
+ try
+ {
+ if (socketChannel.read(buffer) == -1)
+ {
+ throw new ClosedChannelException();
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new ClosedChannelException();
+ }
+ }
}