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

Templates not thread safe when xsl contains call-template.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6
    • 2.7
    • transformation
    • None
    • 2.8GHZ P4, Windows XP SP1, 1GB RAM, JDK 1.4.2_08 (SUN), Xerces-J 2.6.2, Xalan Java 2.6.0

    Description

      Under heavy load (multi-threads), xsl transformations get corrupted. Each thread shares a single cached Templates object and calls newTransformer() to obtain unique Transformer objects. No errors occur if there is no call-template usage in the xsl.

      Please see attached JUnit test, example.xml, and example.xsl. The test fails within the first few seconds of running.

      Here is the expected vs actual results:

      EXPECTED: <?xml version="1.0" encoding="UTF-8"?>
      <transformedDateList>
      <year>2001</year>
      <year>2002</year>
      <year>2003</year>
      <year>2004</year>
      <year>2005</year>
      <year>2006</year>
      <year>2007</year>
      <year>2008</year>
      <year>2009</year>
      <year>2010</year>
      </transformedDateList>

      RECEIVED: <?xml version="1.0" encoding="UTF-8"?>
      <transformedDateList>
      <year>2001</year>
      <year>2002</year>
      <year>2001</year> <---This should have been 2003.
      <year>2004</year>
      <year>2005</year>
      <year>2006</year>
      <year>2007</year>
      <year>2008</year>
      <year>2009</year>
      <year>2010</year>
      </transformedDateList>

      junit.framework.ComparisonFailure: expected:<...3...> but was:<...1...>

      Attachments

        1. example.xsl
          1 kB
          Skow
        2. example.xml
          0.6 kB
          Skow
        3. MultiThreadTestUtility.java
          3 kB
          Skow
        4. TransformTest.java
          2 kB
          Skow

        Activity

          People

            Unassigned Unassigned
            skow Skow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: