diff --git a/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java b/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java index 01a0a2647..778a7cd89 100644 --- a/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java +++ b/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2014 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.util.StringUtils; * class we will have to resolve generic parameters against. * * @author Oliver Gierke + * @author Mark Paluch */ class ParameterizedTypeInformation extends ParentTypeAwareTypeInformation { @@ -85,7 +86,7 @@ class ParameterizedTypeInformation extends ParentTypeAwareTypeInformation } } - return super.getMapValueType(); + return super.doGetMapValueType(); } /* diff --git a/src/test/java/org/springframework/data/util/ParameterizedTypeUnitTests.java b/src/test/java/org/springframework/data/util/ParameterizedTypeUnitTests.java index 5d3f67106..a75b4d618 100644 --- a/src/test/java/org/springframework/data/util/ParameterizedTypeUnitTests.java +++ b/src/test/java/org/springframework/data/util/ParameterizedTypeUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2015 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import org.mockito.runners.MockitoJUnitRunner; * Unit tests for {@link ParameterizedTypeInformation}. * * @author Oliver Gierke + * @author Mark Paluch */ @RunWith(MockitoJUnitRunner.class) public class ParameterizedTypeUnitTests { @@ -137,6 +138,19 @@ public class ParameterizedTypeUnitTests { assertThat(valueType.getProperty("value").getType(), is(typeCompatibleWith(Education.class))); } + /** + * @see DATACMNS-899 + */ + @Test + public void returnsNullMapValueTypeForNonMapProperties(){ + + TypeInformation valueType = ClassTypeInformation.from(Bar.class).getProperty("param"); + TypeInformation mapValueType = valueType.getMapValueType(); + + assertThat(valueType, instanceOf(ParameterizedTypeInformation.class)); + assertThat(mapValueType, is(nullValue())); + } + @SuppressWarnings("serial") class Localized extends HashMap { S value; @@ -152,6 +166,10 @@ public class ParameterizedTypeUnitTests { Localized2 param2; } + class Bar { + List param; + } + class Parameterized { T property; }