-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
Hi,
Spring uses TypeFactory#constructType to resolve entity class to deserialize into in case of controllers inheritance with Generics on base classes.
I made simplified version and localized issue in provided simple test, which is a naive simulation of what's Spring does.
This test is broken in 2.7.x, 2.8.x, master. Works fine in 2.5.x and 2.6.x.
public static class BaseController<Entity extends BaseEntity> {
public void process(Entity entity) {}
}
public static class ImplController extends BaseController<ImplEntity> {}
public static class BaseEntity {}
public static class ImplEntity extends BaseEntity {}
@Test
public void test() throws NoSuchMethodException {
Method proceed = BaseController.class.getMethod("process", BaseEntity.class);
Type entityType = proceed.getGenericParameterTypes()[0];
JavaType resolvedType = new ObjectMapper().getTypeFactory().constructType(entityType, ImplController.class);
assertEquals(ImplEntity.class, resolvedType.getRawClass());
}
So, since 2.7 resolvedType.getRawClass() contains BaseEntity.class, which is incorrect with the provided context.
Metadata
Metadata
Assignees
Labels
No labels