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]