Skip to content

Commit

Permalink
ARTEMIS-3677 mitigate NPE when browsing messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jbertram committed Feb 10, 2022
1 parent 7648e8b commit 51a25b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ public static String truncateString(final String str, final int valueSizeLimit)
}

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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,7 @@ private Map<String, Object> toPropertyMap(boolean expandPropertyType, int valueS
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();
Expand All @@ -876,7 +875,7 @@ private Map<String, Object> toPropertyMap(boolean expandPropertyType, int valueS
// 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));
}
});
}
Expand Down

0 comments on commit 51a25b4

Please sign in to comment.