You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jmeter.apache.org by bu...@apache.org on 2018/04/10 20:53:40 UTC

[Bug 62281] New: Cannot Load MapProperty - java.lang.NullPointerException

https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

            Bug ID: 62281
           Summary: Cannot Load MapProperty -
                    java.lang.NullPointerException
           Product: JMeter
           Version: 4.0
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: Main
          Assignee: issues@jmeter.apache.org
          Reporter: dam6923@gmail.com
  Target Milestone: ---

I'm guessing it's because the default constructor for MapProperty does not
instantiate an internal map and therefore, when the serializer creates an
instance of MapProperty and tries to add a property, it fails.

The CollectionProperty class creates an internal ArrayList when the default
constructor is called, for example.


Caused by: java.lang.NullPointerException
        at
org.apache.jmeter.testelement.property.MapProperty.addProperty(MapProperty.java:137)
~[ApacheJMeter_core.jar:4.0 r1823414]
        at
org.apache.jmeter.testelement.property.MapProperty.addProperty(MapProperty.java:75)
~[ApacheJMeter_core.jar:4.0 r1823414]
        at
org.apache.jmeter.save.converters.MultiPropertyConverter.unmarshal(MultiPropertyConverter.java:71)
~[ApacheJMeter_core.jar:4.0 r1823414]
        at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
~[xstream-1.4.10.jar:1.4.10]
        at
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
~[xstream-1.4.10.jar:1.4.10]
        at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
~[xstream-1.4.10.jar:1.4.10]
        at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
~[xstream-1.4.10.jar:1.4.10]
        at
com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:73)
~[xstream-1.4.10.jar:1.4.10]
        at
org.apache.jmeter.save.converters.MultiPropertyConverter.unmarshal(MultiPropertyConverter.java:69)
~[ApacheJMeter_core.jar:4.0 r1823414]
        at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
~[xstream-1.4.10.jar:1.4.10]
        at
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
~[xstream-1.4.10.jar:1.4.10]
        at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
~[xstream-1.4.10.jar:1.4.10]
        at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
~[xstream-1.4.10.jar:1.4.10]

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

--- Comment #8 from belugabehr <da...@gmail.com> ---
I created it with JUnit and then hand modified it to pull out the irrelevant
parts thereby simplify the error space.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

Felix Schumacher <fe...@internetallee.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |JMETER_4.1
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from Felix Schumacher <fe...@internetallee.de> ---
Thanks for your contribution.

I can't get your jmx file to work, but I think that is because the jmx file is
not correct.

It would be nice, if you could check, whether the fix works for you.

Date: Sun Jun  3 13:44:15 2018
New Revision: 1832768

URL: http://svn.apache.org/viewvc?rev=1832768&view=rev
Log:
Prevent NPE in MapProperty.

Initialize the backing Map when no Map was passed into constructor.
Patch by belugabehr (dam6923 at gmail.com)

Bugzilla Id: 62281

Added:
   
jmeter/trunk/test/src/org/apache/jmeter/testelement/property/MapPropertyTest.java
  (with props)
Modified:
   
jmeter/trunk/src/core/org/apache/jmeter/testelement/property/MapProperty.java
    jmeter/trunk/xdocs/changes.xml

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

UbikLoadPack support <su...@ubikloadpack.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #7 from UbikLoadPack support <su...@ubikloadpack.com> ---
Hello,
How did you create this JMX file ?
Could you provide the program ?

Thanks

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |p.mouawad@ubik-ingenierie.c
                   |                            |om
             Status|NEW                         |NEEDINFO
                 OS|                            |All

--- Comment #1 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
Hello,
Could you provide a reproducer for this issue ?

How does it happen ?
A JMX plan or junit test is very welcome.

Regards

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

--- Comment #9 from belugabehr <da...@gmail.com> ---
I'm guessing it's failing the default constructor for MapProperty does not
instantiate an internal map and therefore, when the serializer creates an
instance of MapProperty and tries to add a property, it fails.

The CollectionProperty class creates an internal ArrayList when the default
constructor is called.  Please do the same for MapProperty.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

--- Comment #5 from belugabehr <da...@gmail.com> ---
Created attachment 35862
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35862&action=edit
JMeter Log File - INFO level

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |FixedInTrunk

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

--- Comment #2 from Philippe Mouawad <p....@ubik-ingenierie.com> ---
(In reply to Philippe Mouawad from comment #1)
> Hello,
> Could you provide a reproducer for this issue ?
> 
> How does it happen ?
> A JMX plan or junit test is very welcome.
> 
> Regards

And jmeter.log

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

--- Comment #6 from belugabehr <da...@gmail.com> ---
Attached requested files.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

Philippe Mouawad <p....@ubik-ingenierie.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

--- Comment #4 from belugabehr <da...@gmail.com> ---
Created attachment 35861
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35861&action=edit
JMX files which causes NPE

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

belugabehr <da...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #3 from belugabehr <da...@gmail.com> ---
Thank you for the quick response.

I am working on a custom component that spits out MapProperty objects.

https://github.com/apache/jmeter/blob/f2e65bc2f264d4bd7da83279dbdcf236da6edfe3/src/core/org/apache/jmeter/save/converters/MultiPropertyConverter.java#L64-L76


#####
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext
context) {
        MultiProperty prop = (MultiProperty)
createCollection(context.getRequiredType());
       
prop.setName(ConversionHelp.decode(reader.getAttribute(ConversionHelp.ATT_NAME)));
        while (reader.hasMoreChildren()) {
            reader.moveDown();
            JMeterProperty subProp = (JMeterProperty) readItem(reader, context,
prop);
            if (subProp != null) { // could be null if it has been deleted via
NameUpdater
                prop.addProperty(subProp);
            }
            reader.moveUp();
        }
        return prop;
    }

#####

The MultiProperty is created, almost certainly with the default constructor,
which does not create a default internal data structure for MapProperty.  It
then calls "addProperty" which triggers the NPE.

The unit test would be to simply create the MapProperty with the default
constructor, then call "addProperty" method on it.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 62281] Cannot Load MapProperty - java.lang.NullPointerException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62281

--- Comment #10 from belugabehr <da...@gmail.com> ---
Created attachment 35879
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35879&action=edit
Proposed patch

-- 
You are receiving this mail because:
You are the assignee for the bug.