CglibAopProxy skips method proxy for equals/hashCode/toString override
Issue: SPR-17500
This commit is contained in:
@@ -74,6 +74,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNullConfig() {
|
||||
new CglibAopProxy(null);
|
||||
@@ -153,6 +154,20 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
|
||||
assertEquals("The name property has been overwritten by the constructor", "Rob Harrop", proxy.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToStringInvocation() {
|
||||
PrivateCglibTestBean bean = new PrivateCglibTestBean();
|
||||
bean.setName("Rob Harrop");
|
||||
|
||||
AdvisedSupport as = new AdvisedSupport();
|
||||
as.setTarget(bean);
|
||||
as.addAdvice(new NopInterceptor());
|
||||
AopProxy aop = new CglibAopProxy(as);
|
||||
|
||||
PrivateCglibTestBean proxy = (PrivateCglibTestBean) aop.getProxy();
|
||||
assertEquals("The name property has been overwritten by the constructor", "Rob Harrop", proxy.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnadvisedProxyCreationWithCallDuringConstructor() {
|
||||
CglibTestBean target = new CglibTestBean();
|
||||
@@ -480,6 +495,29 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class PrivateCglibTestBean {
|
||||
|
||||
private String name;
|
||||
|
||||
public PrivateCglibTestBean() {
|
||||
setName("Some Default");
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -498,6 +536,11 @@ class CglibTestBean {
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user