DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24302>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24302 Threading issue using Templates object and user-defined functions causes random Exceptions Summary: Threading issue using Templates object and user-defined functions causes random Exceptions Product: XalanJ2 Version: 2.5 Platform: PC URL: http://www.davidtiller.com/xalan/xalan-j_2_5_2- threadbug-DET.jar OS/Version: Windows XP Status: NEW Severity: Blocker Priority: Other Component: org.apache.xalan.templates AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Using a Templates object that involves user-defined functions in a multi- threaded program generates frequent but random Exceptions. This problem has been reproduced under Win XP (Sun JVM 1.4.2_b28) and HP/UX 11.11 (build 1.4.1.02-030502-13:44). Full details, stack traces, sample program, sample xml, sample xsl can be found in the jar at http://www.davidtiller.com/xalan/xalan-j_2_5_2-threadbug-DET.jar This problem prevents the efficient use of xalan-j_2.5.x in any EJB unless every EJB in the pool creates its own Transformer object from the same XSL. That is a very time-consuming and memory-intensive proposition. The following xsl (copy of ThreadTest.xsl from the above url) exhibits the problem: Dear Xalan developer, Please find attached a jar file containing a simple Java program and associated XML/XSLT that seem to expose a threading issue in xalan-J version 2.5.2. The enclosed .log files show stack traces from a Windows 2000 platform running Sun's J2SDK-1.4.2_b28 and from an HP/UX platform running HP's "build 1.4.1.02-030502-13:44" JVM. The program does the following: 1) Create a TransformerFactory using TransformerFactory.newInstance(); 2) Use #1 to create a static instance of a Templates object using the supplied ThreadTest.xsl 3) Spin 'n' threads, each of which creates its own transformer from #2, creates a StreamSource representing the supplied ThreadTest.xml, and a StreamResult file (with a unique filename). 4) Each thread uses its local transformer to transform the source into the result 'm' times. 5) The main() routine waits to join() back with all the non-daemon threads. This problem seems to manifest itself when a user-defined function evaluates a statement that involves xsl variables. The following xsl (ThreadTest.xsl) exhibits the problem when used in a multi-threaded program: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:func="http://exslt.org/functions" version="1.0"> <xsl:output method="xml" indent="yes" standalone="yes"/> <func:function name="func:eval"> <xsl:param name="expr" /> <xsl:choose> <xsl:when test="$expr"> <func:result>1</func:result> </xsl:when> <xsl:otherwise> <func:result>0</func:result> </xsl:otherwise> </xsl:choose> </func:function> <xsl:template match="/testxml"> <foobar> <xsl:apply-templates select="foo"/> </foobar> </xsl:template> <xsl:template match="foo"> <xsl:variable name="first" select="@first"/> <xsl:variable name="second" select="@second"/> <match> <xsl:value-of select="func:eval($first = $second)"/> <xsl:value-of select="func:eval($first != $second)"/> <xsl:value-of select="func:eval($first > $second)"/> <xsl:value-of select="func:eval($first < $second)"/> <xsl:value-of select="func:eval($first >= $second)"/> <xsl:value-of select="func:eval($first <= $second)"/> </match> </xsl:template> </xsl:stylesheet>
