You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2009/07/09 01:45:40 UTC

svn commit: r792359 - in /felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio: ThreadInputStream.java ThreadPrintStream.java

Author: gnodet
Date: Wed Jul  8 23:45:39 2009
New Revision: 792359

URL: http://svn.apache.org/viewvc?rev=792359&view=rev
Log:
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)

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java?rev=792359&r1=792358&r2=792359&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java Wed Jul  8 23:45:39 2009
@@ -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();
+    }
 }

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java?rev=792359&r1=792358&r2=792359&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java Wed Jul  8 23:45:39 2009
@@ -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);
+    }
 }