File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
main/java/org/springframework/data/util
test/java/org/springframework/data/util Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
6060 private final Map <Constructor <?>, List <TypeInformation <?>>> constructorParameters = new ConcurrentHashMap <>();
6161 private final Lazy <List <TypeInformation <?>>> typeArguments ;
6262
63- private final Lazy <List <Class >> resolvedGenerics ;
63+ private final Lazy <List <TypeInformation <?> >> resolvedGenerics ;
6464
6565 protected TypeDiscoverer (ResolvableType type ) {
6666
@@ -71,7 +71,9 @@ protected TypeDiscoverer(ResolvableType type) {
7171 this .valueType = Lazy .of (this ::doGetMapValueType );
7272 this .typeArguments = Lazy .of (this ::doGetTypeArguments );
7373 this .resolvedGenerics = Lazy .of (() -> Arrays .stream (resolvableType .getGenerics ()) //
74- .map (ResolvableType ::toClass ).collect (Collectors .toList ()));
74+ .map (TypeInformation ::of ) // use TypeInformation comparison to remove any attachments to variableResolver
75+ // holding the type source
76+ .collect (Collectors .toList ()));
7577 }
7678
7779 static TypeDiscoverer <?> ofCached (ResolvableType type ) {
Original file line number Diff line number Diff line change 2929import org .junit .jupiter .api .Test ;
3030import org .junit .jupiter .api .extension .ExtendWith ;
3131import org .mockito .junit .jupiter .MockitoExtension ;
32+
3233import org .springframework .beans .factory .annotation .Autowire ;
3334import org .springframework .core .ResolvableType ;
3435import org .springframework .data .geo .GeoResults ;
@@ -348,6 +349,15 @@ void differentEqualsAndHashCodeForTypeDiscovererAndClassTypeInformation() {
348349 assertThat (discoverer .hashCode ()).isNotEqualTo (classTypeInformation .hashCode ());
349350 }
350351
352+ @ Test // GH-3051
353+ void considersNestedGenericsInEquality () throws ReflectiveOperationException {
354+
355+ ResolvableType containerList = ResolvableType .forField (WithContainer .class .getDeclaredField ("containerList" ));
356+ ResolvableType containerMap = ResolvableType .forField (WithContainer .class .getDeclaredField ("containerMap" ));
357+
358+ assertThat (TypeInformation .of (containerList )).isNotEqualTo (TypeInformation .of (containerMap ));
359+ }
360+
351361 class Person {
352362
353363 Addresses addresses ;
@@ -441,4 +451,15 @@ class EnumMapWrapper {
441451 class GeoResultsWrapper {
442452 GeoResults <Leaf > results ;
443453 }
454+
455+ static class WithContainer {
456+ MyContainer <List <String >> containerList ;
457+
458+ MyContainer <List <Map <Long , Double >>> containerMap ;
459+ }
460+
461+ static class MyContainer <T > {
462+ T data ;
463+ }
464+
444465}
You can’t perform that action at this time.
0 commit comments