ARTEMIS-3677 mitigate NPE when browsing messages

This commit is contained in:
Justin Bertram 2022-02-09 19:12:34 -06:00
parent 7648e8bac3
commit 51a25b4ba4
No known key found for this signature in database
GPG Key ID: F41830B875BB8633
2 changed files with 5 additions and 3 deletions

View File

@ -338,6 +338,9 @@ public final class JsonUtil {
}
public static Object truncate(final Object value, final int valueSizeLimit) {
if (value == null) {
return "";
}
Object result = value;
if (valueSizeLimit >= 0) {
if (String.class.equals(value.getClass())) {

View File

@ -865,8 +865,7 @@ public abstract class AMQPMessage extends RefCountMessage implements org.apache.
if (value instanceof Binary) {
value = ((Binary)value).getArray();
}
value = JsonUtil.truncate(value, valueSizeLimit);
map.put(applicationPropertiesPrefix + name, value);
map.put(applicationPropertiesPrefix + name, JsonUtil.truncate(value, valueSizeLimit));
}
TypedProperties extraProperties = getExtraProperties();
@ -876,7 +875,7 @@ public abstract class AMQPMessage extends RefCountMessage implements org.apache.
// keep fields like _AMQ_ACTUAL_EXPIRY in their original type
map.put(extraPropertiesPrefix + s.toString(), o);
} else {
map.put(extraPropertiesPrefix + s.toString(), JsonUtil.truncate(o.toString(), valueSizeLimit));
map.put(extraPropertiesPrefix + s.toString(), JsonUtil.truncate(o != null ? o.toString() : o, valueSizeLimit));
}
});
}