Bug 57605 - When there is an error loading Test Plan, SaveService.loadTree returns null leading to NPE in callers
Summary: When there is an error loading Test Plan, SaveService.loadTree returns null l...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.12
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-19 20:26 UTC by Philippe Mouawad
Modified: 2015-02-23 20:20 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2015-02-19 20:26:33 UTC
Currently whenever JMeter Test plan fails to load :
- Missing jars
- Wrong version

You end up getting NullPointerException which does not contain any clue of the initial problem:

2015/02/19 15:40:23 ERROR - jmeter.JMeter: Error in NonGUIDriver java.lang.NullPointerException
        at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:110)
        at org.apache.jmeter.JMeter.runNonGui(JMeter.java:763)
        at org.apache.jmeter.JMeter.startNonGui(JMeter.java:741)
        at org.apache.jmeter.JMeter.start(JMeter.java:399)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.jmeter.NewDriver.main(NewDriver.java:264)


1/ I propose to instead tbrow  new IllegalArgumentException("Error loading jmx file from :"+f+", check log file");

2/ I also propose to change parameter to File instead of Reader to be able to clarify message
Comment 1 Philippe Mouawad 2015-02-19 21:33:02 UTC
Date: Thu Feb 19 21:30:55 2015
New Revision: 1661007

URL: http://svn.apache.org/r1661007
Log:
Bug 57605 - When there is an error loading Test Plan, SaveService.loadTree returns null leading to NPE in callers
Bugzilla Id: 57605

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java
    jmeter/trunk/src/core/org/apache/jmeter/JMeter.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Load.java
    jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
    jmeter/trunk/test/src/org/apache/jmeter/gui/action/TestLoad.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/modifier/TestAnchorModifier.java
    jmeter/trunk/test/src/org/apache/jmeter/save/TestSaveService.java
    jmeter/trunk/xdocs/changes.xml
Comment 2 Sebb 2015-02-23 18:21:48 UTC
(In reply to Philippe Mouawad from comment #0)
> 
> 2/ I also propose to change parameter to File instead of Reader to be able
> to clarify message

This may break 3rd party code.
We cannot just change the public API signature without warning.

The original API needs to be retained, possibly with a a warning that it is deprecated.
Comment 3 Philippe Mouawad 2015-02-23 20:20:42 UTC
Date: Mon Feb 23 20:18:45 2015
New Revision: 1661763

URL: http://svn.apache.org/r1661763
Log:
[Bug 57605] When there is an error loading Test Plan, SaveService.loadTree returns null leading to NPE in callers
Retain backward compatibility as per sebb note
Bugzilla Id: 57605

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java