-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
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