Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-04-18 10:19:31 -0400
committerEike Stepper2012-04-18 10:19:31 -0400
commit7e09bb0246d06b78ee7154574f4bf3ccfb673548 (patch)
tree3f4cbcb838be8894a150b96328c96977c43ab4f2
parent64c38e20fb448f47deac82d8d10e9c8f02340bf5 (diff)
downloadcdo-7e09bb0246d06b78ee7154574f4bf3ccfb673548.tar.gz
cdo-7e09bb0246d06b78ee7154574f4bf3ccfb673548.tar.xz
cdo-7e09bb0246d06b78ee7154574f4bf3ccfb673548.zip
[377094] Payload size of 21331 cause Buffer error when CDO UI is used
https://bugs.eclipse.org/bugs/show_bug.cgi?id=377094
-rw-r--r--plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java10
-rw-r--r--plugins/org.eclipse.net4j.tests/.gitignore1
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java81
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/Buffer.java6
5 files changed, 97 insertions, 11 deletions
diff --git a/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF
index 62f7f943ff..4efab08d5b 100644
--- a/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.jvm/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.net4j.jvm;singleton:=true
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.0.1.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,7 +12,7 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
org.eclipse.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
Import-Package: org.osgi.framework;version="[1.3.0,2.0.0)";resolution:=optional
-Export-Package: org.eclipse.net4j.internal.jvm;version="4.0.0";x-friends:="org.eclipse.net4j.defs,org.eclipse.net4j.tests",
- org.eclipse.net4j.internal.jvm.bundle;version="4.0.0";x-internal:=true,
- org.eclipse.net4j.internal.jvm.messages;version="4.0.0";x-internal:=true,
- org.eclipse.net4j.jvm;version="4.0.0"
+Export-Package: org.eclipse.net4j.internal.jvm;version="4.0.1";x-friends:="org.eclipse.net4j.defs,org.eclipse.net4j.tests",
+ org.eclipse.net4j.internal.jvm.bundle;version="4.0.1";x-internal:=true,
+ org.eclipse.net4j.internal.jvm.messages;version="4.0.1";x-internal:=true,
+ org.eclipse.net4j.jvm;version="4.0.1"
diff --git a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
index 11418811d1..d2189d29da 100644
--- a/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
+++ b/plugins/org.eclipse.net4j.jvm/src/org/eclipse/net4j/internal/jvm/JVMConnector.java
@@ -22,6 +22,7 @@ import org.eclipse.net4j.util.security.INegotiationContext;
import org.eclipse.spi.net4j.Connector;
import org.eclipse.spi.net4j.InternalChannel;
+import java.nio.ByteBuffer;
import java.util.Queue;
/**
@@ -78,6 +79,15 @@ public abstract class JVMConnector extends Connector implements IJVMConnector
Queue<IBuffer> localQueue = localChannel.getSendQueue();
IBuffer buffer = localQueue.poll();
+
+ ByteBuffer byteBuffer = buffer.getByteBuffer();
+ if (byteBuffer.position() == IBuffer.HEADER_SIZE)
+ {
+ // Just release this empty buffer has been written
+ buffer.release();
+ return;
+ }
+
if (TRACER.isEnabled())
{
TRACER.trace("Multiplexing " + buffer.formatContent(true)); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.net4j.tests/.gitignore b/plugins/org.eclipse.net4j.tests/.gitignore
new file mode 100644
index 0000000000..07faf8dbbb
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/.gitignore
@@ -0,0 +1 @@
+/testMap.dat
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java
index 4668527e11..13013a3060 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TransportTest.java
@@ -114,11 +114,11 @@ public abstract class TransportTest extends AbstractProtocolTest
public void testSendBuffer() throws Exception
{
startTransport();
- IConnector iConnecter = getConnector();
- IChannel channel = iConnecter.openChannel();
+ IConnector connecter = getConnector();
+ IChannel channel = connecter.openChannel();
for (int i = 0; i < 3; i++)
{
- IBuffer buffer = provideBuffer(iConnecter);
+ IBuffer buffer = provideBuffer(connecter);
ByteBuffer byteBuffer = buffer.startPutting(channel.getID());
byteBuffer.putInt(1970);
@@ -126,6 +126,31 @@ public abstract class TransportTest extends AbstractProtocolTest
}
}
+ public void testSendEmptyBuffer() throws Exception
+ {
+ startTransport();
+ IConnector connecter = getConnector();
+ IChannel channel = connecter.openChannel();
+ for (int i = 0; i < 3; i++)
+ {
+ IBuffer buffer = provideBuffer(connecter);
+ buffer.startPutting(channel.getID());
+ channel.sendBuffer(buffer);
+ }
+ }
+
+ public void testSendEmptyBuffer2() throws Exception
+ {
+ startTransport();
+ IConnector connecter = getConnector();
+ IChannel channel = connecter.openChannel();
+ for (int i = 0; i < 3; i++)
+ {
+ IBuffer buffer = provideBuffer(connecter);
+ channel.sendBuffer(buffer);
+ }
+ }
+
public void testHandleBuffer() throws Exception
{
final int COUNT = 3;
@@ -133,12 +158,13 @@ public abstract class TransportTest extends AbstractProtocolTest
container.registerFactory(new TestProtocol.ServerFactory(counter));
// need to handle about separating container between client and server for SSL.
registerClientFactory(new TestProtocol.ClientFactory());
+
startTransport();
- IConnector iConnecter = getConnector();
- IChannel channel = iConnecter.openChannel(TestProtocol.ClientFactory.TYPE, null);
+ IConnector connecter = getConnector();
+ IChannel channel = connecter.openChannel(TestProtocol.ClientFactory.TYPE, null);
for (int i = 0; i < COUNT; i++)
{
- IBuffer buffer = provideBuffer(iConnecter);
+ IBuffer buffer = provideBuffer(connecter);
ByteBuffer byteBuffer = buffer.startPutting(channel.getID());
byteBuffer.putInt(1970);
channel.sendBuffer(buffer);
@@ -148,6 +174,49 @@ public abstract class TransportTest extends AbstractProtocolTest
assertEquals(true, counter.await(2, TimeUnit.SECONDS));
}
+ public void testHandleEmptyBuffer() throws Exception
+ {
+ final int COUNT = 3;
+ final CountDownLatch counter = new CountDownLatch(COUNT);
+ container.registerFactory(new TestProtocol.ServerFactory(counter));
+ // need to handle about separating container between client and server for SSL.
+ registerClientFactory(new TestProtocol.ClientFactory());
+
+ startTransport();
+ IConnector connecter = getConnector();
+ IChannel channel = connecter.openChannel(TestProtocol.ClientFactory.TYPE, null);
+ for (int i = 0; i < COUNT; i++)
+ {
+ IBuffer buffer = provideBuffer(connecter);
+ buffer.startPutting(channel.getID());
+ channel.sendBuffer(buffer);
+ sleep(50);
+ }
+
+ assertEquals(COUNT, counter.getCount());
+ }
+
+ public void testHandleEmptyBuffer2() throws Exception
+ {
+ final int COUNT = 3;
+ final CountDownLatch counter = new CountDownLatch(COUNT);
+ container.registerFactory(new TestProtocol.ServerFactory(counter));
+ // need to handle about separating container between client and server for SSL.
+ registerClientFactory(new TestProtocol.ClientFactory());
+
+ startTransport();
+ IConnector connecter = getConnector();
+ IChannel channel = connecter.openChannel(TestProtocol.ClientFactory.TYPE, null);
+ for (int i = 0; i < COUNT; i++)
+ {
+ IBuffer buffer = provideBuffer(connecter);
+ channel.sendBuffer(buffer);
+ sleep(50);
+ }
+
+ assertEquals(COUNT, counter.getCount());
+ }
+
public void testStreaming() throws Exception
{
final int COUNT = 1;
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 46a9fe96dc..7f680fee9b 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
@@ -263,6 +263,12 @@ public class Buffer implements InternalBuffer
{
try
{
+ if (byteBuffer.position() == HEADER_SIZE)
+ {
+ clear();
+ return true; // *Pretend* that this empty buffer has been written
+ }
+
if (state != BufferState.PUTTING && state != BufferState.WRITING)
{
throw new IllegalStateException(toString());

Back to the top