Environment (Required on creation):
Tested with spring camunda starter 7.16.2-ee and spin 1.9.0.
Support ticket: SUPPORT-12786
Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket):
camunda-spin throws NullPointerException with maps containing null values. Probably sets with null values would fail too.
Steps to reproduce (Required on creation):
Create a map with null values and try to serialize it with spin.
See this example: https://github.com/daniel-ewing/spring-boot-spin1/tree/map-with-null-value
Observed Behavior (Required on creation):
NullPointerException
Expected behavior (Required on creation):
Spin should serialize maps with null values successfully (and sets too).
Root Cause (Required on prioritization):
Spin tries to construct a type for the key and value. With null value the value.getClass line throws a NPE in the TypeHelper class:
org/camunda/spin/impl/json/jackson/format/TypeHelper.java:78
Solution Ideas (Optional):
- Introduce null check. Try to determine the value type by looking at other, non-null values, or store Object as type (since iterating a full map can be expensive)
- Make sure to to test it for Set with null value.
- What if a map only contains a single entry with null value? We can't determine the type... Store Object as type.
Hints (optional):
-