CglibAopProxy skips method proxy for equals/hashCode/toString override

Issue: SPR-17500
This commit is contained in:
Juergen Hoeller
2018-11-20 22:04:28 +01:00
parent f5aeb81473
commit 2a5d7690b6
2 changed files with 51 additions and 5 deletions

View File

@@ -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;
}
}