Do not consider bridge methods in SpEL properties
Modify ReflectivePropertyAccessor so that it no longer considers bridge methods when finding getters or setters. This should help to prevent subtle errors that can occur when particular JDK implementations happen to return bridge methods before non-bridge methods when calling Class.getMethods() Issue: SPR-9994
This commit is contained in:
@@ -50,6 +50,10 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.expression.spel.support.StandardTypeLocator;
|
||||
import org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.isA;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
@@ -1633,6 +1637,25 @@ public class SpelReproTests extends ExpressionTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBridgeMethods_SPR_9994() throws Exception {
|
||||
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
Object target = new GenericImplementation();
|
||||
TypedValue value = accessor.read(context, target , "property");
|
||||
assertEquals(Integer.class, value.getTypeDescriptor().getType());
|
||||
}
|
||||
|
||||
private static interface GenericInterface<T extends Number> {
|
||||
public T getProperty();
|
||||
}
|
||||
|
||||
private static class GenericImplementation implements GenericInterface<Integer> {
|
||||
public Integer getProperty() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user