Closed
Description
In a Spring Boot application we use Spring Data Mongo to map some documents. Some of them have embedded documents with a hierarchy, e.g.:
@Document("projects")
@TypeAlias("project")
data class Project(
...
val budget: ProjectBudget)
abstract class ProjectBudget {
abstract fun getCurrentBudget(): MonetaryAmount?
}
@TypeAlias("projectProjectBudget")
class ClosedProjectBudget(... ) : ProjectBudget() {}
Up to Spring Boot 2.4.3 when retrieving a Project instance the corresponding ProjectBudget subclass what built correctly. However after the upgrade to Boot 2.4.4 we get this exception:
Caused by: java.lang.InstantiationError: xxx.ProjectBudget
at xxx.ProjectBudget_Instantiator_srp3na.newInstance(Unknown Source)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:238)
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:87)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:344)
There seems to be a regression when instantiating subclasses.