-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reassign property of Type Map fails with an EmptyStack exception #144
Comments
Thx. I'm on it. |
Can you please send the mapping configuration or a reproducing, minimal example? |
Findings: Currently the mapper analyzes the type of properties. If the source value of a property is an instance of a Map, the map conversion is triggered. The map conversion creates a map instance using Collectors.toMap function. The map instance might not be assignment compatible with the target value of the bean. This is some kind of hidden convention: The problem does not occur as long as the bean properties use super types like Map, List, Set etc.
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 |
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:
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.
The text was updated successfully, but these errors were encountered: