Skip to content

TypeInformation loses track of actual type parameter. #2312

Closed
@christophstrobl

Description

@christophstrobl

When resolving the TypeInformation for properties via TypeInformation.getProperty the actual type parameter might be lost and be replaced by java.lang.Object if the property is declared in a super type.

Related issue: spring-projects/spring-data-mongodb#3567

class SomeGeneric<T> {
	T value;
}

class GenericExtendingSomeGeneric<T> extends SomeGeneric<T> { }

class Wrapper {
	GenericExtendingSomeGeneric<Leaf> field;
}

@Test
void typeInfoShouldPreserveGenericParameter() {

	TypeInformation<Wrapper> wrapperTypeInfo = from(Wrapper.class);
	TypeInformation<?> fieldTypeInfo = wrapperTypeInfo.getProperty("field");
	TypeInformation<?> valueTypeInfo = fieldTypeInfo.getProperty("value");

	assertThat(valueTypeInfo.getType()).isEqualTo(Leaf.class);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions