AutoCloseInputStream.read() throws IOException after autoclose
--------------------------------------------------------------

                 Key: IO-228
                 URL: https://issues.apache.org/jira/browse/IO-228
             Project: Commons IO
          Issue Type: Bug
          Components: Streams/Writers
    Affects Versions: 1.4
         Environment: Apple Inc. Java HotSpot(TM) 64-Bit Server VM 1.6.0_17; 
Mac OS X 10.5.8 (x86_64)
            Reporter: Brett Johnson


A custom reported a problem, wherein our product was catching and logging many 
IOExceptions.  Upon examining the logs I see:

java.io.IOException: Attempted read on closed stream.
        at 
org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
        at 
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107)
        at java.io.FilterInputStream.read(FilterInputStream.java:116)
        at 
com.acme.DocPusher$BigEmptyDocumentFilterInputStream.read(DocPusher.java:679)
        at 
com.acme.CompressedFilterInputStream.fillbuff(CompressedFilterInputStream.java:96)
        at 
com.acme.CompressedFilterInputStream.read(CompressedFilterInputStream.java:67)
        at 
com.acme.Base64FilterInputStream.fillbuff(Base64FilterInputStream.java:138)
        at 
com.acme.Base64FilterInputStream.read(Base64FilterInputStream.java:115)
        at java.io.FilterInputStream.read(FilterInputStream.java:116)
        at 
com.acme.DocPusher$AlternateContentFilterInputStream.read(DocPusher.java:609)
        ...

As you can see, this is a pipeline consisting of multiple FilterInputStream 
segments that process data flowing through the pipeline.  The source of the 
data is in InputStream provided by a third party plug-in component.  In our 
customer's situation, that InputStream is a AutoCloseInputStream returned by a 
Sharepoint API call.

When I saw the "Attempted read on closed stream.", I was incredulous; "Reading 
from a closed stream - that's a rookie mistake."  However, when examining the 
JavaDoc for AutoCloseInputStream, I read:  [emphasis mine]
"Proxy stream that closes and discards the underlying stream *as soon as the 
end of input has been reached* or when the stream is explicitly closed."





-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to