This project demonstrate how to reproduce a bug with ModelMapper
The project is a simple Maven project with Java 11
The test framework is JUnit 5 and AssertJ
The test demonstrates the bug.
- Have a list of some
SourceType-> mappings of elements of that list get added toMappingContextImpl.sourceToDestination - Have another property of that
SourceTypethat is equal to any element of the list -> the property of theDestinationTypegets added toMappingContextImpl.intermediateDestination - Have another property of that
SourceTypethat is NOT equal to any other element of the list -> in methodMappingContextImpl.getParentDestination,intermediateDestinationis searched for any instance of DestinationType. The first instance found is returned - the properties of the returned instance are updated with properties of the source instance, thus corrupting other fields of
DestinationTypethat use that instance.