Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-227

AutoCloseInputStream.read() throws IOException after autoclose

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.4
    • None
    • Streams/Writers
    • None
    • Apple Inc. Java HotSpot(TM) 64-Bit Server VM 1.6.0_17; Mac OS X 10.5.8 (x86_64)

    Description

      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."

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              brettmjohnson Brett Johnson
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: