On 11 December 2015 at 21:23,  <[email protected]> wrote:
> Author: pmouawad
> Date: Fri Dec 11 21:23:21 2015
> New Revision: 1719569
>
> URL: http://svn.apache.org/viewvc?rev=1719569&view=rev
> Log:
> comment that file cannot be null
>
> Modified:
>     
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java
>
> Modified: 
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java
> URL: 
> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java?rev=1719569&r1=1719568&r2=1719569&view=diff
> ==============================================================================
> --- 
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java
>  (original)
> +++ 
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java
>  Fri Dec 11 21:23:21 2015
> @@ -161,6 +161,7 @@ public class WebServiceSampler extends H
>              File src = new File(this.getXmlPathLoc());
>              if (src.isDirectory() && src.list() != null) {
>                  File [] fileList = src.listFiles(new JMeterFileFilter(new 
> String[] { ".xml" }, false));
> +                // fileList cannot be null as we checked it

Not strictly true.
Although we know that the src File was a directory, the listFiles()
method can still return null if an IO error occurs.
Also in theory the directory can be deleted in the window between
checking it and listing it.

It would be safer to dispense with the pre-checks and check for a null response.


>                  File one = 
> fileList[ThreadLocalRandom.current().nextInt(fileList.length)];
>                  // return the absolutePath of the file
>                  return one.getAbsolutePath();
>
>

Reply via email to