Uploaded image for project: 'Cocoon'
  1. Cocoon
  2. COCOON-2340

XMLByteStreamCompiler in not thread-safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.2
    • None
    • * Cocoon Core
    • None
    • Normal
    • Components: Pipeline - 1.0.0

    Description

      I'm periodically getting the following exceptions in different places:

      Caused by: java.lang.ArrayIndexOutOfBoundsException
              at java.lang.System.arraycopy(Native Method)
              at org.apache.cocoon.components.sax.XMLByteStreamCompiler.getSAXFragment(XMLByteStreamCompiler.java:61)
              at org.apache.cocoon.components.pipeline.impl.ExpiresCachingProcessingPipeline.processXMLPipeline(ExpiresCachingProcessingPipeline.java:152)

      After debugging I've found the root cause. It happens due to multi-threading when one thread allocates newbuf array, then another thread increments bufCount in write method and then the first thread fails on System.arraycopy invocation.

      I suggest making getSAXFragment and write methods synchronized. It should resolve the issue. If it helps, I'll provide a patch later.

      Attachments

        Activity

          People

            jpuerto Javier Puerto
            lagivan Ivan Lagunov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: