summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-08-08 23:36:10 (EDT)
committerCaspar De Groot2010-08-08 23:36:10 (EDT)
commitd7b7e805fcaa005e635b617a5f8d213830c201fa (patch)
treea7a8bbebdfb306cb45c086e046d82f384d94934c
parent0e71cdc9d02fe58ec654ed3481879b760cc225cd (diff)
downloadcdo-d7b7e805fcaa005e635b617a5f8d213830c201fa.zip
cdo-d7b7e805fcaa005e635b617a5f8d213830c201fa.tar.gz
cdo-d7b7e805fcaa005e635b617a5f8d213830c201fa.tar.bz2
[321484] Buffer.startGetting does not always handle remote socket closure gracefully
https://bugs.eclipse.org/bugs/show_bug.cgi?id=321484
-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();
+ }
+ }
}