commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [1/3] [lang] #LAN-1114 fixes bug in TypeUtils.equals(WildcardType, Type) where it was incorrectly returning true when the second argument was not a Wildcard type.
Date Wed, 29 Apr 2015 17:48:58 GMT
Repository: commons-lang
Updated Branches:
  refs/heads/master 6965455f8 -> 640953167


#LAN-1114 fixes bug in TypeUtils.equals(WildcardType, Type) where it was incorrectly returning
true when the second argument was not a Wildcard type.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/e2c0ea43
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/e2c0ea43
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/e2c0ea43

Branch: refs/heads/master
Commit: e2c0ea4374c02539ad9bc6c4328b74f25eb72405
Parents: 63d8a02
Author: The Datalorax <datalorax@gmail.com>
Authored: Tue Apr 28 21:07:21 2015 +0100
Committer: The Datalorax <datalorax@gmail.com>
Committed: Tue Apr 28 21:07:21 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/lang3/reflect/TypeUtils.java |  2 +-
 .../org/apache/commons/lang3/reflect/TypeUtilsTest.java  | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e2c0ea43/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
index 1a750e9..91313c6 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
@@ -1626,7 +1626,7 @@ public class TypeUtils {
             return equals(getImplicitLowerBounds(w), getImplicitLowerBounds(other))
                 && equals(getImplicitUpperBounds(w), getImplicitUpperBounds(other));
         }
-        return true;
+        return false;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e2c0ea43/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
index 60c8b48..56b23a2 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
@@ -97,6 +97,8 @@ public class TypeUtilsTest<B> {
 
     public static Comparable<Long> longComparable;
 
+    public static Comparable<?> wildcardComparable;
+
     public static URI uri;
 
     public void dummyMethod(final List list0, final List<Object> list1, final List<?>
list2,
@@ -723,6 +725,15 @@ public class TypeUtilsTest<B> {
     }
 
     @Test
+    public void testLang1114() throws Exception {
+        final Type nonWildcardType = getClass().getDeclaredField("wildcardComparable").getGenericType();
+        final Type wildcardType = ((ParameterizedType)nonWildcardType).getActualTypeArguments()[0];
+
+        Assert.assertFalse(TypeUtils.equals(wildcardType, nonWildcardType));
+        Assert.assertFalse(TypeUtils.equals(nonWildcardType, wildcardType));
+    }
+
+    @Test
     public void testGenericArrayType() throws Exception {
         final Type expected = getClass().getField("intWildcardComparable").getGenericType();
         final GenericArrayType actual =


Mime
View raw message