Make sure to delegate all methods to the underlying print stream to avoid deadlocks (as the print stream classes are synchronized, but we only use a single instance for all threads)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@792359 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java
index 8d869ac..e3dfe2b 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java
@@ -31,16 +31,6 @@
dflt = in;
}
- public int read(byte[] buffer, int offset, int length) throws IOException
- {
- return getCurrent().read(buffer, offset, length);
- }
-
- public int read(byte[] buffer) throws IOException
- {
- return getCurrent().read(buffer);
- }
-
private InputStream getCurrent()
{
InputStream in = map.get();
@@ -51,11 +41,6 @@
return dflt;
}
- public int read() throws IOException
- {
- return getCurrent().read();
- }
-
public void setStream(InputStream in)
{
if (in != dflt && in != this)
@@ -83,4 +68,52 @@
return dflt;
}
+ //
+ // Delegate methods
+ //
+
+ public int read() throws IOException
+ {
+ return getCurrent().read();
+ }
+
+ public int read(byte[] b) throws IOException
+ {
+ return getCurrent().read(b);
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException
+ {
+ return getCurrent().read(b, off, len);
+ }
+
+ public long skip(long n) throws IOException
+ {
+ return getCurrent().skip(n);
+ }
+
+ public int available() throws IOException
+ {
+ return getCurrent().available();
+ }
+
+ public void close() throws IOException
+ {
+ getCurrent().close();
+ }
+
+ public void mark(int readlimit)
+ {
+ getCurrent().mark(readlimit);
+ }
+
+ public void reset() throws IOException
+ {
+ getCurrent().reset();
+ }
+
+ public boolean markSupported()
+ {
+ return getCurrent().markSupported();
+ }
}
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java
index 0a8c529..241fa27 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.io.InputStream;
+import java.util.Locale;
public class ThreadPrintStream extends PrintStream
{
@@ -33,16 +34,6 @@
dflt = out;
}
- public void write(byte[] buffer, int offset, int length)
- {
- getCurrent().write(buffer, offset, length);
- }
-
- public void write(byte[] buffer) throws IOException
- {
- getCurrent().write(buffer);
- }
-
public PrintStream getCurrent()
{
PrintStream out = map.get();
@@ -53,11 +44,6 @@
return dflt;
}
- public void write(int b)
- {
- getCurrent().write(b);
- }
-
public void setStream(PrintStream out)
{
if (out != dflt && out != this)
@@ -85,4 +71,177 @@
return dflt;
}
+ //
+ // Delegate methods
+ //
+
+ public void flush()
+ {
+ getCurrent().flush();
+ }
+
+ public void close()
+ {
+ getCurrent().close();
+ }
+
+ public boolean checkError()
+ {
+ return getCurrent().checkError();
+ }
+
+ public void setError()
+ {
+// getCurrent().setError();
+ }
+
+ public void clearError()
+ {
+// getCurrent().clearError();
+ }
+
+ public void write(int b)
+ {
+ getCurrent().write(b);
+ }
+
+ public void write(byte[] buf, int off, int len)
+ {
+ getCurrent().write(buf, off, len);
+ }
+
+ public void print(boolean b)
+ {
+ getCurrent().print(b);
+ }
+
+ public void print(char c)
+ {
+ getCurrent().print(c);
+ }
+
+ public void print(int i)
+ {
+ getCurrent().print(i);
+ }
+
+ public void print(long l)
+ {
+ getCurrent().print(l);
+ }
+
+ public void print(float f)
+ {
+ getCurrent().print(f);
+ }
+
+ public void print(double d)
+ {
+ getCurrent().print(d);
+ }
+
+ public void print(char[] s)
+ {
+ getCurrent().print(s);
+ }
+
+ public void print(String s)
+ {
+ getCurrent().print(s);
+ }
+
+ public void print(Object obj)
+ {
+ getCurrent().print(obj);
+ }
+
+ public void println()
+ {
+ getCurrent().println();
+ }
+
+ public void println(boolean x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(char x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(int x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(long x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(float x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(double x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(char[] x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(String x)
+ {
+ getCurrent().println(x);
+ }
+
+ public void println(Object x)
+ {
+ getCurrent().println(x);
+ }
+
+ public PrintStream printf(String format, Object... args)
+ {
+ return getCurrent().printf(format, args);
+ }
+
+ public PrintStream printf(Locale l, String format, Object... args)
+ {
+ return getCurrent().printf(l, format, args);
+ }
+
+ public PrintStream format(String format, Object... args)
+ {
+ return getCurrent().format(format, args);
+ }
+
+ public PrintStream format(Locale l, String format, Object... args)
+ {
+ return getCurrent().format(l, format, args);
+ }
+
+ public PrintStream append(CharSequence csq)
+ {
+ return getCurrent().append(csq);
+ }
+
+ public PrintStream append(CharSequence csq, int start, int end)
+ {
+ return getCurrent().append(csq, start, end);
+ }
+
+ public PrintStream append(char c)
+ {
+ return getCurrent().append(c);
+ }
+
+ public void write(byte[] b) throws IOException
+ {
+ getCurrent().write(b);
+ }
}