the fail silently slipped by. It's suppose to log to jmeter's log, but due to oversight on my part, it doesn't. I'll patch it tonight. rather than make it threadlocal, I think I will just make it non static.
peter On Apr 1, 2005 3:43 PM, KiYun Roe <[EMAIL PROTECTED]> wrote: > Sure. The errors I saw manifested themselves as unsuccessful results in View > Results Tree, etc. The statement > > openDocument(null).getDocumentElement(); > > at about line 405 in WebServiceSampler.jar was throwing a null pointer > exception, because the call to XDB.parse() was failing inside openDocument() > (because document builders are not thread safe). The null pointer exception > was caught at line 595 of WebServiceSampler.java, resulting in a call to > RESULT.setSuccessful(false)--hence, the unsuccessful result. > > I personally found it easier to reproduce the problem by hitting a very > simple web service on another machine from a basic multi-threaded test plan. > I guess the key is to spend as little time as possible invoking the web > service, so that proportionally more time is spent preparing the call--thus > increasing the odds of finding more than one thread in the problematic code. > > I have to say that I'm mystified by the practice of catching exceptions and > failing silently as demonstrated in openDocument(). I hope that's just > temporary. > > -- KiYun > > -----Original Message----- > From: Peter Lin [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 31, 2005 10:53 PM > To: JMeter Developers List > Subject: Re: WebSerivceSampler not thread safe > > thanks for the patch, i'll take a look this weekend when I get a > chance. Out of curiousity, what kind of errors are you seeing. I've > tested and profiled the sampler on several occasions using OptimizeIt > and wasn't able to see any errors. any additional information you can > provide would help make sure the bug is really fixed. > > thanks > > peter > > On Mar 31, 2005 9:38 PM, KiYun Roe <[EMAIL PROTECTED]> wrote: > > Hi, > > > > There's a comment at about line 108 of > org.apache.jmeter.protocol.http.sampler.WebServiceSampler.java expressing > concern that sharing a single DocumentBuilder might not be thread safe. > Well, it's not. This explains the intermittent, mysterious failures that > I've seen testing a web service from multiple JMeter threads. > > > > Here's a possible patch using a ThreadLocal to allocate one > DocumentBuilder per thread. I'm new to Jakarta. How do I get this into the > source distribution? > > > > Thanks. > > > > -- KiYun Roe > > > > Index: > src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler. > java > > =================================================================== > > RCS file: > /home/cvspublic/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/ > http/sampler/WebServiceSampler.java,v > > retrieving revision 1.17 > > diff -b -u -w -r1.17 WebServiceSampler.java > > --- > src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler. > java 6 Jan 2005 01:11:43 -0000 1.17 > > +++ > src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler. > java 1 Apr 2005 02:16:39 -0000 > > @@ -112,7 +112,14 @@ > > * consider using Apache commons pool to create a pool of document > builders > > * or make sure XMLParserUtils creates builders efficiently. > > */ > > - private static DocumentBuilder XDB = null; > > + private static ThreadLocal ThreadLocalXDB = > > + new ThreadLocal() > > + { > > + protected Object initialValue() > > + { > > + return XMLParserUtils.getXMLDocBuilder(); > > + } > > + }; > > > > private String FILE_CONTENTS = null; > > > > @@ -413,10 +420,7 @@ > > */ > > protected Document openDocument(String key) > > { > > - if (XDB == null) > > - { > > - XDB = XMLParserUtils.getXMLDocBuilder(); > > - } > > + DocumentBuilder XDB = (DocumentBuilder) > ThreadLocalXDB.get(); > > Document doc = null; > > // if either a file or path location is given, > > // get the file object. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
