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

Restore threadlocal for skipfully() byte buffer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      Over on TIKA-4065, we found that trying to upgrade to commons-io 2.12.0 or 2.13.0 caused one of our unit tests to fail. We found that dropping threadlocal on the buffer used in IOUtils.skipFully() in conjunction with Java's InflaterInputStream was the cause of the problem.

      Our unit test shows that running skipFully() on a stream and then reading gets different results on the same underlying stream when running multithreaded. This is really bad. It appears to be confined to InflaterInputStream...so not a very common case.

      On the commons-io's user list psteitz observed that Java's InflaterInputStream expects read access to the byte array passed in...so having multiple threads writing to the same static (not-thread local) byte array is dangerous. The behavior of Java's InflaterInputStream is surprising and not documented.

      I have a demonstration of the problem here: https://github.com/tballison/commons-io/blob/TIKA-4065/src/test/java/org/apache/commons/io/IOUtilsMultithreadedTest.java

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tallison Tim Allison
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: