You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Marcel Offermans (Created) (JIRA)" <ji...@apache.org> on 2012/02/03 09:51:53 UTC

[jira] [Created] (FELIX-3336) Exceptions related to the pipe used in deployment admin

Exceptions related to the pipe used in deployment admin
-------------------------------------------------------

                 Key: FELIX-3336
                 URL: https://issues.apache.org/jira/browse/FELIX-3336
             Project: Felix
          Issue Type: Bug
          Components: Deployment Admin
            Reporter: Marcel Offermans


Sporadically getting "Pipe closed" exceptions. Not reproducible yet, but seemingly related to a line containing "input.close()" in the ExplodingOutputtingInputStream. Needs investigation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3336) Exceptions related to the pipe used in deployment admin

Posted by "Marcel Offermans (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199665#comment-13199665 ] 

Marcel Offermans commented on FELIX-3336:
-----------------------------------------

A solution has been committed, but I'm not quite sure why it works. If you do a checkout, and run "mvn clean install" the test succeeds. If you apply this patch:

{code}

Index: src/main/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStream.java
===================================================================
--- src/main/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStream.java	(revision 1240137)
+++ src/main/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStream.java	(working copy)
@@ -73,7 +73,7 @@
         super(inputStream, output);
         m_contentDir = root;
         m_indexFile = index;
-        m_input = new PipedInputStream(output /*, 8 FELIX-3336: if you provide such a small buffer, the error is reproducible (see below) */);
+        m_input = new PipedInputStream(output , 8 /* FELIX-3336: if you provide such a small buffer, the error is reproducible (see below) */);
         m_task = new Thread(this, "Apache Felix DeploymentAdmin - ExplodingOutputtingInputStream");
         m_task.start();
     }
@@ -129,16 +129,16 @@
             }
         }
         // FELIX-3336: if you include this code, the issue is gone
-        try {
-            byte[] bb = new byte[512];
-            int c = m_input.read(bb);
-            while (c != -1) {
-                c = m_input.read(bb);
-            }
-        }
-        catch (IOException e) {
-            e.printStackTrace();
-        }
+//        try {
+//            byte[] bb = new byte[512];
+//            int c = m_input.read(bb);
+//            while (c != -1) {
+//                c = m_input.read(bb);
+//            }
+//        }
+//        catch (IOException e) {
+//            e.printStackTrace();
+//        }
     }

{code}

And then run the test again, you get:

{code}

$ cat target/surefire-reports/org.apache.felix.deploymentadmin.ExplodingOutputtingInputStreamTest.txt 
-------------------------------------------------------------------------------
Test set: org.apache.felix.deploymentadmin.ExplodingOutputtingInputStreamTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.071 sec <<< FAILURE!
testStream(org.apache.felix.deploymentadmin.ExplodingOutputtingInputStreamTest)  Time elapsed: 1.057 sec  <<< ERROR!
java.io.IOException: Read end dead
	at java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:246)
	at java.io.PipedInputStream.awaitSpace(PipedInputStream.java:252)
	at java.io.PipedInputStream.receive(PipedInputStream.java:215)
	at java.io.PipedOutputStream.write(PipedOutputStream.java:132)
	at org.apache.felix.deploymentadmin.OutputtingInputStream.read(OutputtingInputStream.java:58)
	at org.apache.felix.deploymentadmin.ExplodingOutputtingInputStreamTest.testStream(ExplodingOutputtingInputStreamTest.java:47)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [...]

{code}

For some weird reason the read blocks and finally generates an exception because the pipe has been closed. I have no clue why the read blocks though, and why reading extra bytes from an underlying stream (m_input) that should have already been read completely (this ZipInputStream reads everything it should) unblocks the read. Admittedly, this is not the easiest piece of code to read, but I can't find a fundamental flaw in the approach. Maybe someone else can. :)
                
> Exceptions related to the pipe used in deployment admin
> -------------------------------------------------------
>
>                 Key: FELIX-3336
>                 URL: https://issues.apache.org/jira/browse/FELIX-3336
>             Project: Felix
>          Issue Type: Bug
>          Components: Deployment Admin
>            Reporter: Marcel Offermans
>
> Sporadically getting "Pipe closed" exceptions. Not reproducible yet, but seemingly related to a line containing "input.close()" in the ExplodingOutputtingInputStream. Needs investigation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (FELIX-3336) Exceptions related to the pipe used in deployment admin

Posted by "J.W. Janssen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199767#comment-13199767 ] 

J.W. Janssen commented on FELIX-3336:
-------------------------------------

After some debugging, it appears that a ZipInputStream does *not* read all bytes from the underlying input stream, but stops after the last ZIP-entry (after this the central directory of the ZIP file is stored, which is not used by the implementation). Hence, the ExplodingOutputtingInputStream thinks it has read all underlying bytes, but in fact this is not the case. So, it terminates, while the other end still is processing the last couple of bytes (= central directory of ZIP-file). This explains why the above error occurs.

A solution would be to read the last couple of bytes in the input stream after the ZipInputStream is finished...
                
> Exceptions related to the pipe used in deployment admin
> -------------------------------------------------------
>
>                 Key: FELIX-3336
>                 URL: https://issues.apache.org/jira/browse/FELIX-3336
>             Project: Felix
>          Issue Type: Bug
>          Components: Deployment Admin
>            Reporter: Marcel Offermans
>
> Sporadically getting "Pipe closed" exceptions. Not reproducible yet, but seemingly related to a line containing "input.close()" in the ExplodingOutputtingInputStream. Needs investigation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (FELIX-3336) Exceptions related to the pipe used in deployment admin

Posted by "Marcel Offermans (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-3336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marcel Offermans reassigned FELIX-3336:
---------------------------------------

    Assignee: Marcel Offermans
    
> Exceptions related to the pipe used in deployment admin
> -------------------------------------------------------
>
>                 Key: FELIX-3336
>                 URL: https://issues.apache.org/jira/browse/FELIX-3336
>             Project: Felix
>          Issue Type: Bug
>          Components: Deployment Admin
>            Reporter: Marcel Offermans
>            Assignee: Marcel Offermans
>
> Sporadically getting "Pipe closed" exceptions. Not reproducible yet, but seemingly related to a line containing "input.close()" in the ExplodingOutputtingInputStream. Needs investigation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (FELIX-3336) Exceptions related to the pipe used in deployment admin

Posted by "J.W. Janssen (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-3336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199767#comment-13199767 ] 

J.W. Janssen edited comment on FELIX-3336 at 2/3/12 3:26 PM:
-------------------------------------------------------------

After some debugging, it appears that a ZipInputStream does *not* read all bytes from the underlying input stream, but stops after the last ZIP-entry (after this the central directory of the ZIP file is stored, which is not used by the implementation). Hence, the ExplodingOutputtingInputStream thinks it has read all underlying bytes, but in fact this is not the case. So, it terminates, while the other end still is processing the last couple of bytes (= central directory of ZIP-file). This explains why the above error occurs.

A solution would be to read the last couple of bytes in the input stream after the ZipInputStream is finished...

PS: one of the reasons why this might spuriously occur in real life is that the buffer size of PipedInputStream is large enough to read those last couple of bytes of the ZIP file...
                
      was (Author: jajans):
    After some debugging, it appears that a ZipInputStream does *not* read all bytes from the underlying input stream, but stops after the last ZIP-entry (after this the central directory of the ZIP file is stored, which is not used by the implementation). Hence, the ExplodingOutputtingInputStream thinks it has read all underlying bytes, but in fact this is not the case. So, it terminates, while the other end still is processing the last couple of bytes (= central directory of ZIP-file). This explains why the above error occurs.

A solution would be to read the last couple of bytes in the input stream after the ZipInputStream is finished...
                  
> Exceptions related to the pipe used in deployment admin
> -------------------------------------------------------
>
>                 Key: FELIX-3336
>                 URL: https://issues.apache.org/jira/browse/FELIX-3336
>             Project: Felix
>          Issue Type: Bug
>          Components: Deployment Admin
>            Reporter: Marcel Offermans
>
> Sporadically getting "Pipe closed" exceptions. Not reproducible yet, but seemingly related to a line containing "input.close()" in the ExplodingOutputtingInputStream. Needs investigation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira