From f0dbad518541ba8142c7db3762d1941e7eb889cd Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 13 May 2016 11:32:14 +0200 Subject: [PATCH] DATACMNS-855 - Fixed generic type lookup in SyntheticParamterizedType. The translation of the list of actual type parameters into an array now uses the loop index correctly. Previously, it always used the first type parameter. --- .../springframework/data/util/TypeDiscoverer.java | 2 +- .../data/util/ClassTypeInformationUnitTests.java | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/data/util/TypeDiscoverer.java b/src/main/java/org/springframework/data/util/TypeDiscoverer.java index 8877b1d6c..f13ffd84d 100644 --- a/src/main/java/org/springframework/data/util/TypeDiscoverer.java +++ b/src/main/java/org/springframework/data/util/TypeDiscoverer.java @@ -597,7 +597,7 @@ class TypeDiscoverer implements TypeInformation { Type[] result = new Type[typeParameters.size()]; for (int i = 0; i < typeParameters.size(); i++) { - result[i] = typeParameters.get(0).getType(); + result[i] = typeParameters.get(i).getType(); } return result; diff --git a/src/test/java/org/springframework/data/util/ClassTypeInformationUnitTests.java b/src/test/java/org/springframework/data/util/ClassTypeInformationUnitTests.java index 83169819c..5f9e42b5f 100644 --- a/src/test/java/org/springframework/data/util/ClassTypeInformationUnitTests.java +++ b/src/test/java/org/springframework/data/util/ClassTypeInformationUnitTests.java @@ -355,6 +355,7 @@ public class ClassTypeInformationUnitTests { /** * @see DATACMNS-783 + * @see DATACMNS-853 */ @Test public void specializesTypeUsingTypeVariableContext() { @@ -366,6 +367,7 @@ public class ClassTypeInformationUnitTests { assertThat(specialized.getType(), is((Object) Bar.class)); assertThat(specialized.getProperty("field").getType(), is((Object) Character.class)); + assertThat(specialized.getProperty("anotherField").getType(), is((Object) Integer.class)); } /** @@ -575,16 +577,17 @@ public class ClassTypeInformationUnitTests { static class Leaf {} - static class TypeWithAbstractGenericType { - AbstractBar abstractBar; + static class TypeWithAbstractGenericType { + AbstractBar abstractBar; Object object; } - static class Foo extends TypeWithAbstractGenericType {} + static class Foo extends TypeWithAbstractGenericType {} - static abstract class AbstractBar {} + static abstract class AbstractBar {} - static class Bar extends AbstractBar { + static class Bar extends AbstractBar { T field; + S anotherField; } }