felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From db...@apache.org
Subject svn commit: r950123 - /felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
Date Tue, 01 Jun 2010 15:43:45 GMT
Author: dbaum
Date: Tue Jun  1 15:43:44 2010
New Revision: 950123

URL: http://svn.apache.org/viewvc?rev=950123&view=rev
Log:
fixed lock contention in piped writer when reader doesn't read all input (FELIX-2380)

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java?rev=950123&r1=950122&r2=950123&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java (original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java Tue Jun
 1 15:43:44 2010
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 import java.io.PrintStream;
+import java.lang.reflect.Method;
 import java.util.List;
 
 import org.apache.felix.service.command.Converter;
@@ -43,7 +44,7 @@ public class Pipe extends Thread
 
     public static Object[] mark()
     {
-        Object[] mark = {tIn.get(), tOut.get(), tErr.get() };
+        Object[] mark = { tIn.get(), tOut.get(), tErr.get() };
         return mark;
     }
 
@@ -101,7 +102,7 @@ public class Pipe extends Thread
         tOut.set(out);
         tErr.set(err);
         closure.session().threadIO().setStreams(in, out, err);
-        
+
         try
         {
             result = closure.executeStatement(statement);
@@ -124,16 +125,23 @@ public class Pipe extends Thread
 
             try
             {
-                if (in instanceof PipedInputStream)
-                {
-                    in.close();
-                }
                 if (pout != null)
                 {
                     pout.close();
                 }
+
+                if (in instanceof PipedInputStream)
+                {
+                    in.close();
+
+                    // avoid writer waiting when reader has given up (FELIX-2380)
+                    Method m = in.getClass().getDeclaredMethod("receivedLast",
+                        (Class<?>[]) null);
+                    m.setAccessible(true);
+                    m.invoke(in, (Object[]) null);
+                }
             }
-            catch (IOException e)
+            catch (Exception e)
             {
                 e.printStackTrace();
             }



Mime
View raw message