Consider bridge methods in SpEL properties

Revert ReflectivePropertyAccessor changes from 107fafb and instead
consider all methods when resolving properties. Methods are now
sorted such that non-bridge methods are considered before bridge
methods.

Issue: SPR-10162
This commit is contained in:
Phillip Webb
2013-01-11 14:55:52 -08:00
parent 5ddc313bef
commit fce7adc400
2 changed files with 43 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,6 +56,7 @@ import static org.junit.Assert.*;
* @author Andy Clement
* @author Juergen Hoeller
* @author Clark Duplichien
* @author Phillip Webb
*/
public class SpelReproTests extends ExpressionTestCase {
@@ -1656,6 +1657,15 @@ public class SpelReproTests extends ExpressionTestCase {
assertEquals(Integer.class, value.getTypeDescriptor().getType());
}
@Test
public void SPR_10162_onlyBridgeMethodTest() throws Exception {
ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
StandardEvaluationContext context = new StandardEvaluationContext();
Object target = new OnlyBridgeMethod();
TypedValue value = accessor.read(context, target , "property");
assertEquals(Integer.class, value.getTypeDescriptor().getType());
}
@Test
public void SPR_10091_simpleTestValueType() {
ExpressionParser parser = new SpelExpressionParser();
@@ -1722,4 +1732,15 @@ public class SpelReproTests extends ExpressionTestCase {
}
}
static class PackagePrivateClassWithGetter {
public Integer getProperty() {
return null;
}
}
public static class OnlyBridgeMethod extends PackagePrivateClassWithGetter {
}
}