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: r1661007 - in /jmeter/trunk: src/components/org/apache/jmeter/control/ src/core/org/apache/jmeter/ src/core/org/apache/jmeter/gui/action/ src/core/org/apache/jmeter/save/ test/src/org/apache/jmeter/gui/action/ test/src/org/apache/jmeter/pro...
Date Mon, 23 Feb 2015 18:25:50 GMT
On 19 February 2015 at 21:30,  <pmouawad@apache.org> wrote:
> Author: pmouawad
> 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

-1, see below.

> 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
>
...
> Modified: jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java?rev=1661007&r1=1661006&r2=1661007&view=diff
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java Thu Feb 19 21:30:55
2015
> @@ -19,6 +19,7 @@
>  package org.apache.jmeter.save;
>
>  import java.io.BufferedInputStream;
> +import java.io.File;
>  import java.io.FileInputStream;
>  import java.io.IOException;
>  import java.io.InputStream;
> @@ -506,40 +507,44 @@ public class SaveService {
>
>      /**
>       * Load a Test tree (JMX file)
> -     * @param reader on the JMX file
> +     * @param file the JMX file
>       * @return the loaded tree
>       * @throws IOException if there is a problem reading the file or processing it
>       */
> -    public static HashTree loadTree(InputStream reader) throws IOException {
> -        if (!reader.markSupported()) {
> -            reader = new BufferedInputStream(reader);
> -        }
> -        reader.mark(Integer.MAX_VALUE);
> -        ScriptWrapper wrapper = null;
> +    public static HashTree loadTree(File file) throws IOException {

-1

This breaks the API.

The code needs to be fixed so that it continues to support the method:

 public static HashTree loadTree(InputStream reader) throws IOException

It should be easy enough to do this without much code duplication.

> +        log.info("Loading file: " + file);
> +        InputStream reader = null;
>          try {
> -            // Get the InputReader to use
> -            InputStreamReader inputStreamReader = getInputStreamReader(reader);
> -            wrapper = (ScriptWrapper) JMXSAVER.fromXML(inputStreamReader);
> -            inputStreamReader.close();
> -            if (wrapper == null){
> -                log.error("Problem loading XML: see above.");
> -                return null;
> +            reader = new FileInputStream(file);

Mime
View raw message