jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1719569 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java
Date Fri, 11 Dec 2015 23:33:48 GMT
On 11 December 2015 at 21:23,  <pmouawad@apache.org> 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();
>
>

Mime
View raw message