Hi all, @Chris: No, you did nothing wrong. The tests in the local thread package just show that the exceptions disappear, which result from the concurrent access to EMPTY_DOC (e.g. EMPTY_DOC.importNode()). These exceptions are thrown in the initializeFromXml() method.
However, in the tread local test still multiple threads try to access the same DOM elements in the source EPRs (the _xml member variable). This is taken into account by the shared EPR test cases. Here the DOM elements in the shared source EPRs are created with unique documents. The test still uses the thread local mechanism DOM operations, hence it shows quite well that the remaining exception from the thread local test case result from the concurrent read access to the _xml object in the EPRs, which in turn were all created in one shared DOM document, EMPTY_DOC. In my opinion, if we create an DOM element what we intend to share later on with multiple threads, we need to create them in a unique document (or even omit DOM member variables in these objects). This is to make the read access thread safe. If we don't intend to share objects later on, we just have to make sure that one DOM document is only use by one thread at a time. This is done by ThreadLocal. Regards, Oliver initializeFromXML(TestEndpointReference.java:560) -------- Original-Nachricht -------- > Datum: Thu, 6 Sep 2007 17:00:09 +0200 > Von: [EMAIL PROTECTED] > An: [email protected] > Betreff: RE: EMPTY_DOC thread stability issues > Hi all, > > @Oliver, I've tried running the tests but I get NPE's from both the > threadlocal version and the current version. Have I run something > incorrectly? > > java.lang.NullPointerException > at org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source) > at org.apache.xerces.dom.ParentNode.item(Unknown Source) > at > org.apache.muse.test.thread.local.TestEndpointReference.<init>(TestEndpo > intReference.java:197) > at > org.apache.muse.test.thread.local.TestThread.run(TestThread.java:60) > java.lang.NullPointerException > at org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source) > at org.apache.xerces.dom.ParentNode.item(Unknown Source) > at > org.apache.muse.test.thread.local.TestEndpointReference.<init>(TestEndpo > intReference.java:197) > at > org.apache.muse.test.thread.local.TestThread.run(TestThread.java:60) > > the shared epr and seperate docs versions shows no errors. > > The seperate doc one takes for ever, quite a performance hit on both the > synchronized for getLocalDoc, which shouldn't be necessary since > newInstance is threadsafe on DocumentBuilderFactory and the > createDocument. I replaced the getLocalDoc with : > > static final ThreadLocal tls = new ThreadLocal(){ > protected Object initialValue() { > DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > factory.setNamespaceAware(true); > factory.setIgnoringComments(true); > try > { > return factory.newDocumentBuilder(); > } > catch (ParserConfigurationException error) > { > throw new > RuntimeException(error.getMessage(), error); > } > } > }; > > public static Document getLocalDoc() { > return ((DocumentBuilder)tls.get()).newDocument(); > } > > and it improved the performance considerably (equal with the current > solution, but correct). Creating new documentbuilder factories is > extremly expensive, jar lookups resource creation, class loading etc. > > cheers, > Chris > > PS A drop in replacement of a customised axis 1.4 - does namespaces etc > correctly - runs in 128 secs (half+ the speed of the current buggy > impl). If others are interested this version doesn't suffer threading > issues on read only, it just creates a few too many things but it could > be stripped down into a usable general dom. > PPS I'm going to start working with Vinhs tests now. > > -----Original Message----- > From: Vinh Nguyen (vinguye2) [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 06, 2007 3:45 AM > To: [email protected] > Subject: RE: EMPTY_DOC thread stability issues > > My test case has been posted to JIRA Muse-270: > > https://issues.apache.org/jira/browse/MUSE-270 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
