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]
Hello, Could you provide a reproducer for this issue ? How does it happen ? A JMX plan or junit test is very welcome. Regards
(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
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.
Created attachment 35861 [details] JMX files which causes NPE
Created attachment 35862 [details] JMeter Log File - INFO level
Attached requested files.
Hello, How did you create this JMX file ? Could you provide the program ? Thanks
I created it with JUnit and then hand modified it to pull out the irrelevant parts thereby simplify the error space.
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.
Created attachment 35879 [details] Proposed patch
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
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4752