I've patched the bug my making the document builder non static. please
give it a try.

thanks again for reporting it.

peter lin

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]

Reply via email to