Hello,
There is a bug in Confluence Server 7.7+ in DefaultConversionContext#immutableProperties at line 82.
public ImmutableMap<String, Object> immutableProperties() {
final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
for (Map.Entry<String, Object> entry : properties.entrySet()) {
final Object value = entry.getValue();
// simple impl, grab primitives and strings
if (value instanceof String || Primitives.isWrapperType(value.getClass())) { // NPE HERE !!!!
builder.put(entry);
}
}
return builder.build();
}
The bug is that there is no null check for the value var in this statement:
if (value instanceof String || Primitives.isWrapperType(value.getClass()))
The value can be (and is, sometimes) null. In that case the instanceof check is false so it tries value.getClass() and blows up w/ an NPE.
Can someone from Atlassian fix this right away?
I’m investigating right now and don’t yet know why there is a null value in the map but IMO that doesn’t matter… the Map can hold null values so null checks are necessary for any code that uses the values.
I have not seen the problem until 7.7+ so maybe something fairly recently added null values to the map. The lack of a null check has been around since well before 7.7. Who knows… probably doesn’t matter… null check map values.
java.lang.NullPointerException
at com.atlassian.confluence.content.render.xhtml.DefaultConversionContext.immutableProperties(DefaultConversionContext.java:82)
at <my macro>
Thanks.