remap
remap copied to clipboard
Reassign property of Type Map fails with an EmptyStack exception
Hi guys, I noticed you had an old PR regarding this issue but I am still facing this exact issue on 4.2.6
.
Below is an amateur way to replicate the issue:
@GetMapping("/test-mapping") public String testMapper() { FromObject from = new FromObject(); from.setFromId("id"); LinkedHashMap<String, String> hashMapValue = new LinkedHashMap<>(); hashMapValue.put("key1", "value1"); hashMapValue.put("key2", "value2"); from.setFromMap(hashMapValue); ToObject toObject = objectMapper.map(from); return "OK"; }
And here is the stack trace:
java.util.EmptyStackException: null at java.base/java.util.Stack.peek(Stack.java:101) at com.remondis.remap.GenericParameterContext.get(GenericParameterContext.java:88) at com.remondis.remap.GenericParameterContext.findNextGenericTypeFromMethod(GenericParameterContext.java:119) at com.remondis.remap.GenericParameterContext.goInto(GenericParameterContext.java:105) at com.remondis.remap.ReassignTransformation.convertMap(ReassignTransformation.java:108) at com.remondis.remap.ReassignTransformation._convert(ReassignTransformation.java:75) at com.remondis.remap.ReassignTransformation.performValueTransformation(ReassignTransformation.java:61) at com.remondis.remap.ReassignTransformation.performTransformation(ReassignTransformation.java:48) at com.remondis.remap.Transformation.performTransformation(Transformation.java:86) at com.remondis.remap.ReassignTransformation.performTransformation(ReassignTransformation.java:23) at com.remondis.remap.MappingConfiguration.map(MappingConfiguration.java:727) at com.remondis.remap.MappingConfiguration.map(MappingConfiguration.java:707) at com.remondis.remap.Mapper.map(Mapper.java:40)
I decompiled the jar and noticed that the issue only happens when the property of the source is of type Map
.
Now I do have a few workarounds for this on my side:
- Downgrade to version 4.1.0
- Store those
Map
properties as custom POJOs (my current implementation includesMap
types only because ofjackson mapper
so the Map type is not necessary there)
However I just wanted to let you guys know on the issue since it was strange for me at first. I would not expect the mapper to just break all of the sudden.
Thx. I'm on it.
Can you please send the mapping configuration or a reproducing, minimal example? I'm able to reproduce an exception, but it's not the one you mentioned.
I created a PR to reproduce the problem. See #145, is this what you did in your mapping config?
Sorry @schuettec, been mad busy. Yeap that is pretty much it. So using a super type seems like a workaround, but IDK if you guys see it as a long term fix. There could be numerous cases where the bean properties could be non-super types created by another library such as jackson
or something else.