summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-28 06:30:00 (EDT)
committerEike Stepper2007-08-28 06:30:00 (EDT)
commit1bd289810db5f04b9a163cf3cebf42e8befaa486 (patch)
tree43c16d7d71e0aca7a85f2b25bd075a53007afb18
parentf6ad99d58e45b2a67c882e69be22eb8ffaa71f03 (diff)
downloadcdo-1bd289810db5f04b9a163cf3cebf42e8befaa486.zip
cdo-1bd289810db5f04b9a163cf3cebf42e8befaa486.tar.gz
cdo-1bd289810db5f04b9a163cf3cebf42e8befaa486.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java43
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/stream/BufferInputStream.java19
5 files changed, 57 insertions, 11 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
index 83e7bc1..981edda 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/GZIPStreamWrapper.java
@@ -10,9 +10,13 @@
**************************************************************************/
package org.eclipse.net4j.util.io;
+import org.eclipse.net4j.util.HexUtil;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -53,4 +57,43 @@ public class GZIPStreamWrapper implements IStreamWrapper<GZIPInputStream, GZIPOu
{
out.finish();
}
+
+ public static void main(String[] args) throws Exception
+ {
+ final PipedOutputStream pos = new PipedOutputStream();
+ final PipedInputStream pis = new PipedInputStream(pos);
+
+ final GZIPOutputStream gos = new GZIPOutputStream(pos);
+ final byte[] out = "eike".getBytes();
+
+ Thread thread = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ GZIPInputStream gis = new GZIPInputStream(pis);
+
+ byte[] in = new byte[out.length];
+ gis.read(in);
+ gis.close();
+ System.out.println("Read: " + HexUtil.bytesToHex(in));
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
+ }
+ };
+
+ thread.start();
+ Thread.sleep(1000);
+
+ gos.write(out);
+ gos.close();
+ System.out.println("Written: " + HexUtil.bytesToHex(out));
+
+ Thread.sleep(2000);
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
index e149cbc..79fa4b8 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithResponse.java
@@ -53,7 +53,7 @@ public abstract class IndicationWithResponse extends SignalReactor
OutputStream wrappedOutputStream = wrapOutputStream(out);
responding(ExtendedDataOutputStream.wrap(wrappedOutputStream));
finishOutputStream(wrappedOutputStream);
- out.flush();
+ out.flushWithEOS();
}
protected abstract void indicating(ExtendedDataInputStream in) throws IOException;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
index 66bfe54..9207489 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Request.java
@@ -45,7 +45,7 @@ public abstract class Request extends SignalActor
OutputStream wrappedOutputStream = wrapOutputStream(out);
requesting(ExtendedDataOutputStream.wrap(wrappedOutputStream));
finishOutputStream(wrappedOutputStream);
- out.flush();
+ out.flushWithEOS();
}
protected abstract void requesting(ExtendedDataOutputStream out) throws IOException;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
index 4caabda..8261522 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithConfirmation.java
@@ -47,7 +47,7 @@ public abstract class RequestWithConfirmation<RESULT> extends SignalActor<RESULT
OutputStream wrappedOutputStream = wrapOutputStream(out);
requesting(ExtendedDataOutputStream.wrap(wrappedOutputStream));
finishOutputStream(wrappedOutputStream);
- out.flush();
+ out.flushWithEOS();
if (TRACER.isEnabled())
{
TRACER.trace("================ Confirming " + ReflectUtil.getSimpleClassName(this)); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/stream/BufferInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/stream/BufferInputStream.java
index 81fa7c3..85325d1 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/stream/BufferInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/stream/BufferInputStream.java
@@ -55,16 +55,19 @@ public class BufferInputStream extends InputStream implements IBufferHandler
@Override
public int read() throws IOException
{
- if (eos && currentBuffer == null)
+ if (currentBuffer == null)
{
- // End of sequence
- return -1;
- }
+ if (eos)
+ {
+ // End of stream
+ return -1;
+ }
- if (!ensureBuffer())
- {
- // Timeout or interrupt
- return -1;
+ if (!ensureBuffer())
+ {
+ // Timeout or interrupt
+ return -1;
+ }
}
final int result = currentBuffer.getByteBuffer().get() & 0xFF;