You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2020. It is now read-only.
When there are no additional properties in the request, the additionalProperties map in POJO is null. This leads to NPE in AdditionalPropertiesSerializer.
Code which can be used to reproduce the issue is:
public static void main(String[] args) throws JsonProcessingException {
final ObjectMapper objectMapper = new ObjectMapperProducer().objectMapper();
final ClassWithAdditionalProperties classWithAdditionalProperties = new ClassWithAdditionalProperties(3, null);
final String serializedClassWithAdditionalProperties = objectMapper.writeValueAsString(classWithAdditionalProperties);
System.out.println(serializedClassWithAdditionalProperties);
}
public static class ClassWithAdditionalProperties {
private final int value;
private final Map<String, Object> additionalProperties;
public ClassWithAdditionalProperties(final int value, final Map<String, Object> additionalProperties) {
this.value = value;
this.additionalProperties = additionalProperties;
}
public int getValue() {
return value;
}
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}
}
Not sure if it is better to defend against NPE (probably would work, why not?) or change the framework in another place to set the empty map...
The text was updated successfully, but these errors were encountered:
@MartinYSpasov / @allanmckenzie
When there are no additional properties in the request, the additionalProperties map in POJO is null. This leads to NPE in
AdditionalPropertiesSerializer
.Code which can be used to reproduce the issue is:
Not sure if it is better to defend against NPE (probably would work, why not?) or change the framework in another place to set the empty map...
The text was updated successfully, but these errors were encountered: