Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2321

Multi-threading problem with AVTs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.7.1
    • Xalan
    • None
    • multi-processor systems
    • PatchAvailable

    Description

      The following code in AVT.java is causing problems for multi-threaded test cases:

      private final FastStringBuffer getBuffer(){
      if(USE_OBJECT_POOL)

      { return StringBufferPool.get(); }

      else if(m_cachedBuf == null)

      { m_cachedBuf = new FastStringBuffer(INIT_BUFFER_CHUNK_BITS); return m_cachedBuf; }

      else if(m_cachedBuf.length() != 0)

      { return new FastStringBuffer(INIT_BUFFER_CHUNK_BITS); }else{ return m_cachedBuf; }
      }

      Because the same object node for the AVT is used by each thread, sometimes on one thread the buffer would be empty just as another thread is writing to it and thus both threads would write to the same buffer. This caused problems for a customer that used <xsl:element name="{local-name()}"> a lot and were running on a multi-processor machine.

      The suggested fix is to change the code to the following, and remove the m_cachedBuf field:

      private final FastStringBuffer getBuffer(){
      if(USE_OBJECT_POOL){ return StringBufferPool.get(); }else{ return new FastStringBuffer(INIT_BUFFER_CHUNK_BITS); }

      }

      Attachments

        1. AVT.patch
          1 kB
          Erin Harris

        Issue Links

          Activity

            People

              Unassigned Unassigned
              eharris Erin Harris
              Yash Talwar Yash Talwar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: