[
https://issues.apache.org/jira/browse/LANG-1114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14514814#comment-14514814
]
ASF GitHub Bot commented on LANG-1114:
--------------------------------------
GitHub user datalorax reopened a pull request:
https://github.com/apache/commons-lang/pull/65
#LANG-1114 TypeUtils.equals is broken for WildcardType
TypeUtils.equals is broken for WildcardType, when compared with
non-wildcard type.
It was broken because it was returning true! Now returns false. Also added
test to cover the issue.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/datalorax/commons-lang
bug/LANG-1114-TypeUtils.ParameterizedType#equals_does_not_work_with_wildcard_types
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-lang/pull/65.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #65
----
commit b053737c2e64303cfcaca0fb07c1f13d352a7b8e
Author: The Datalorax <[email protected]>
Date: 2015-04-18T21:14:06Z
#LANG-1114 TypeUtils.equals is broken for WildcardType, when compared with
non-wildcard type.
It was broken because it was returning true! Now returns false. Also added
test to highlight issue.
commit d55588f1cb7775d655c0cde091899b2443854617
Author: The Datalorax <[email protected]>
Date: 2015-04-18T22:00:34Z
#LANG-1114 Update changes.xml with fix
----
> TypeUtils.ParameterizedType#equals doesn't work with wildcard types
> -------------------------------------------------------------------
>
> Key: LANG-1114
> URL: https://issues.apache.org/jira/browse/LANG-1114
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.reflect.*
> Affects Versions: 3.3.2, 3.4
> Reporter: andrew coates
> Assignee: Benedikt Ritter
> Fix For: Review Patch
>
>
> There is a bug in TypeUtils.equals(WilcardType, Type). It returns true if
> the other type is not a WildcardType, it should return false. See
> TypeUtils@1629 for v3.3.2 and TypeUtils@791 for v3.4
> Bug can be seen with the following test:
> {code}
> @Test
> public void shouldHandleEqualityOfParameterizedTypesWithWildcards()
> throws Exception {
> // Given:
> class SomeType {
> Collection<?> field;
> }
> final ParameterizedType wildcardCollectionType = (ParameterizedType)
> SomeType.class.getDeclaredField("field").getGenericType();
> final WildcardType wildcard = (WildcardType)
> wildcardCollectionType.getActualTypeArguments()[0];
> final ParameterizedType ptWithWildcard =
> TypeUtils.parameterize(Collection.class, wildcard);
> final ParameterizedType otherPt =
> TypeUtils.parameterize(Collection.class, String.class);
> // Then:
> assertThat(otherPt, is(not(equalTo(ptWithWildcard)))); // Passes
> assertThat(ptWithWildcard, is(not(equalTo(otherPt)))); // Fails
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)