jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Possible NPE in FileServer
Date Tue, 10 Feb 2015 23:43:45 GMT
On 9 February 2015 at 02:27, Andrey Pokhilko <apc4@ya.ru> wrote:
> The log piece looks like this:
>
> 2015/02/08 18:26:38 INFO  - jmeter.services.FileServer: Stored:
> /tmp/test.csv
> 2015/02/08 18:26:38 ERROR - jmeter.threads.JMeterThread: Test failed!
> java.lang.IllegalArgumentException: Could not read file header line
>     at
> org.apache.jmeter.services.FileServer.reserveFile(FileServer.java:282)

That's quite reasonable - it's impossible to read a header line if it
is not present.

>     at
> org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java:178)
>     at
> org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:408)
>     at
> org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:400)
>     at
> org.apache.jmeter.control.GenericController.next(GenericController.java:162)
>     at
> org.apache.jmeter.control.LoopController.next(LoopController.java:123)
>     at
> org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:88)
>     at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:259)
>     at java.lang.Thread.run(Thread.java:745)
> Caused by: java.io.FileNotFoundException: /tmp/test.csv (No such file or
> directory)

And here is the original cause

>     at java.io.FileInputStream.open(Native Method)
>     at java.io.FileInputStream.<init>(FileInputStream.java:146)
>     at
> org.apache.jmeter.services.FileServer.createBufferedReader(FileServer.java:399)
>     at org.apache.jmeter.services.FileServer.readLine(FileServer.java:325)
>     at org.apache.jmeter.services.FileServer.readLine(FileServer.java:309)
>     at
> org.apache.jmeter.services.FileServer.reserveFile(FileServer.java:280)
>     ... 8 more
>
> 2015/02/08 18:26:38 INFO  - jmeter.threads.ThreadGroup: Started thread
> group number 2
> 2015/02/08 18:26:38 INFO  - jmeter.threads.JMeterThread: Thread
> finished: Thread Group 1-1
> 2015/02/08 18:26:38 INFO  - jmeter.engine.StandardJMeterEngine: All
> thread groups have been started
> 2015/02/08 18:26:38 INFO  - jmeter.threads.JMeterThread: Thread started:
> Thread Group 2-1
> 2015/02/08 18:26:38 ERROR - jmeter.threads.JMeterThread: Test failed!
> java.lang.NullPointerException
>     at java.io.StringReader.<init>(StringReader.java:50)
>     at
> org.apache.jmeter.save.CSVSaveService.csvSplitString(CSVSaveService.java:1155)

Not good to have an NPE.
The problem is that CSVDataSet.java:178 does not check whether the
header returned by reserveFile is null or not.

It could do so, but assuming that the header line has not been read
because the file is missing, it's not really going to help much.
The FileServer should perhaps be changed to return IOException if the
file cannot be read, rather than returning a null header.

This needs a bit more investigation, but there's definitely a bug here.

>     at
> org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java:180)
>     at
> org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:408)
>     at
> org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:400)
>     at
> org.apache.jmeter.control.GenericController.next(GenericController.java:162)
>     at
> org.apache.jmeter.control.LoopController.next(LoopController.java:123)
>     at
> org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:88)
>     at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:259)
>     at java.lang.Thread.run(Thread.java:745)
>
> 2015/02/08 18:26:38 INFO  - jmeter.threads.JMeterThread: Thread
> finished: Thread Group 2-1
>
> Andrey Pokhilko
>
> On 02/08/2015 04:16 PM, sebb wrote:
>> On 8 February 2015 at 17:08, Andrey Pokhilko <apc4@ya.ru> wrote:
>>> It occurs when you have CSV Data Set and specified file was not found.
>>> Then in the log there is one exception about "file not found" and many
>>> of NPE, I guess for every iteration.
>> Which class?
>> What line number?
>>
>>> Andrey Pokhilko
>>>
>>> On 02/08/2015 04:36 AM, sebb wrote:
>>>> On 6 February 2015 at 22:48, Andrey Pokhilko <apc4@ya.ru> wrote:
>>>>> Hi,
>>>>>
>>>>> I just met the situation, when this line of code returns null and
>>>>> causing NPE:
>>>>> https://github.com/apache/jmeter/blob/31c3385075bff2140a4c2b6cdaa2c4a4c1a4a76e/src/core/org/apache/jmeter/services/FileServer.java#L286
>>>>>
>>>>> fileEntry.headerLine will be non-null only if hasHeader parameter is
>>>>> true. Is this what expected?
>>>> The Javadoc says the method can return null.
>>>>
>>>> Where does the NPE occur?
>>>>
>>>>> --
>>>>> Andrey Pokhilko
>>>>>
>

Mime
View raw message