Hi,
with version 5.3.2, inheritance mapping with map-ids is not always working correctly. The attached project demonstrates the issue. In my concrete usecase I have JAXB-generated classes, with a base-class that is not abstract and several classes extending this base-class. In my mapping files, I have a mapping for the common properties in the base-class plus additional mappings for class-specific extensions, as described in the docs (http://dozer.sourceforge.net/documentation/baseattributes.html). For the extending classes I am using map-ids. This setup was working nicely up until Dozer 5.3.1. With 5.3.2 the inheritance mapping was slightly changed:
The class in question is
org.dozer.classmap.ClassMappings
The following method was changed:
findInterfaceMapping
in 5.3.1:
if (destClass.isAssignableFrom(mappingDestClass) ||
(mappingDestClass.isInterface() && mappingDestClass.isAssignableFrom(destClass))) {
if (MappingUtils.getRealClass(srcClass).equals(mappingSrcClass)) {
return map;
}
}
in 5.3.2:
// Destination could be an abstract type. Picking up the best concrete type to use.
if ((destClass.isAssignableFrom(mappingDestClass) && isAbstract(destClass)) ||
(isInterfaceImplementation(destClass, mappingDestClass))) {
if (MappingUtils.getRealClass(srcClass).equals(mappingSrcClass)) {
return map;
}
}
I tracked the issue down to the "isAbstract(destClass)" method call, which in my case breaks the mapping. My base-class is not abstract and I cannot change this, since it was generated by JAXB. From my point of view the isAbstract() check should either be removed or appended in a separate OR clause.
You can reproduce the issue by extracting the attached maven project and running "mvn test". Switching the dozer-version in the pom.xml to 5.3.1 will resolve the issue.
Can you please fix this for the next version?
Best regards,
Tom
Demo project