Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnionMethodMatcher and ClassFilterAwareUnionMethodMatcher have broken eqauls. [SPR-10604] #15233

Closed
spring-issuemaster opened this issue May 29, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented May 29, 2013

Ivan Sopov opened SPR-10604 and commented

I was investigating the "instanceof vs getClass()== in equals method" problem across the spring framework code-base. It seems that any custom implementation of AbstractResource relying on its equals will lead to inconsistency with all the standard Spring implementations. But I have found a pair of classes with broken equals contract in the spring-aop library:

import org.springframework.aop.MethodMatcher;
import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.MethodMatchers;

public class MethodMatchersEqualsTest
{
public static void main(String[] args)
{
MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
MethodMatcher second = new ComposablePointcut(MethodMatcher.TRUE).union(
new ComposablePointcut(MethodMatcher.TRUE)).getMethodMatcher();

    System.out.println(first.equals(second));
    System.out.println(second.equals(first));
}

}

This code will output:
true
false
So the equals contract is broken for this pair of MethodMatchers.


Affects: 3.2.3

Referenced from: commits f329140, e30b842

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 2, 2013

Juergen Hoeller commented

Good catch! Fixed for 3.2.4 and 4.0 RC1 now.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.