ARTEMIS-653 Possible Null Pointer Exception during message properties read using XmlDataImporter

Create SimpleString object only if value of attribute is not null
This commit is contained in:
Martin Styk 2016-07-25 17:21:50 +02:00 committed by Clebert Suconic
parent a6e934e189
commit 46aad5b3a7
1 changed files with 6 additions and 5 deletions

View File

@ -376,7 +376,8 @@ public final class XmlDataImporter extends ActionAbstract {
String key = ""; String key = "";
String value = ""; String value = "";
String propertyType = ""; String propertyType = "";
String realValue = null; String realStringValue = null;
SimpleString realSimpleStringValue = null;
for (int i = 0; i < reader.getAttributeCount(); i++) { for (int i = 0; i < reader.getAttributeCount(); i++) {
String attributeName = reader.getAttributeLocalName(i); String attributeName = reader.getAttributeLocalName(i);
@ -420,15 +421,15 @@ public final class XmlDataImporter extends ActionAbstract {
break; break;
case XmlDataConstants.PROPERTY_TYPE_SIMPLE_STRING: case XmlDataConstants.PROPERTY_TYPE_SIMPLE_STRING:
if (!value.equals(XmlDataConstants.NULL)) { if (!value.equals(XmlDataConstants.NULL)) {
realValue = value; realSimpleStringValue = new SimpleString(value);
} }
message.putStringProperty(new SimpleString(key), new SimpleString(realValue)); message.putStringProperty(new SimpleString(key), realSimpleStringValue);
break; break;
case XmlDataConstants.PROPERTY_TYPE_STRING: case XmlDataConstants.PROPERTY_TYPE_STRING:
if (!value.equals(XmlDataConstants.NULL)) { if (!value.equals(XmlDataConstants.NULL)) {
realValue = value; realStringValue = value;
} }
message.putStringProperty(key, realValue); message.putStringProperty(key, realStringValue);
break; break;
} }
} }