[ 
http://issues.apache.org/jira/browse/XALANJ-1811?page=comments#action_12319050 
] 

Brian Minchau commented on XALANJ-1811:
---------------------------------------

Frank, I've verified that the current documentation (for the 2.7 release) 
mentions the threading issues in
the javadoc now:
http://xml.apache.org/xalan-j/apidocs/org/apache/xpath/CachedXPathAPI.html#CachedXPathAPI

As the issue creator, please close this issue down. Thanks.

> JavaDoc for CachedXPathAPI should state it's not thread-safe
> ------------------------------------------------------------
>
>          Key: XALANJ-1811
>          URL: http://issues.apache.org/jira/browse/XALANJ-1811
>      Project: XalanJ2
>         Type: Bug
>   Components: XPath
>     Versions: 2.2.x
>  Environment: Operating System: Windows NT/2K
> Platform: PC
>     Reporter: Frank Tewissen
>      Fix For: 2.7

>
> Version: Xalan bundled with jdk1.4.2_02 (crimson parser)
> Using an instance of the CachedXPathAPI class from within multiple threads on 
> a 
> document that is not changed at runtime, causes inconsistent behaviour.
> The source code below reproduces that problem on Windows NT (same is true for 
> Linux RedHat7.3). Hint: I was only able to reproduce the problem when using a 
> condition (e.g. [EMAIL PROTECTED]'a']) in the xpath statement.
> ----------------------------------------------------------
> import java.io.*;
> import javax.xml.parsers.*;
> import org.apache.xpath.CachedXPathAPI;
> import org.w3c.dom.*;
> import org.xml.sax.*;
> public class CachedXPathAPITest {
>     private static final String XML = "<document><node id='a'>a</node><node 
> id='b'>b</node><node id='c'>c</node></document>";
>     private CachedXPathAPI _api;
>     private Document _doc;
>     public CachedXPathAPITest() throws Exception {
>         _api = new CachedXPathAPI();
>         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
>         DocumentBuilder parser = factory.newDocumentBuilder();
>         _doc = parser.parse(new InputSource(new StringReader(XML)));
>         Thread t = null;
>         for (int i=0; i<200; i++)
>             t = new TestThread(_api, _doc);
>         t.join();
>     }
>     public static void main(String[] args) throws Exception {
>         new CachedXPathAPITest();
>     }
>     class TestThread extends Thread {
>         private CachedXPathAPI _api;
>         private Document _doc;
>         TestThread(CachedXPathAPI api, Document doc) {
>             _api = api;
>             _doc = doc;
>             start();
>         }
>         public void run() {
>             try {
>                 for (int i=0; i<100; i++) {
>                     String a = _api.eval(_doc, "/document/[EMAIL 
> PROTECTED]'a']").str();
>                     if (!a.equals("a"))
>                         throw new RuntimeException(a + "!=a");
>                     String b = _api.eval(_doc, "/document/[EMAIL 
> PROTECTED]'b']").str();
>                     if (!b.equals("b"))
>                         throw new RuntimeException(b + "!=b");
>                     String c = _api.eval(_doc, "/document/[EMAIL 
> PROTECTED]'c']").str();
>                     if (!c.equals("c"))
>                         throw new RuntimeException(c + "!=c");
>                 }
>             } catch (Exception e) {
>                 System.err.println(e);
>             }
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to