TargetSource.getTarget() is nullable again (for compatibility with MethodInvocation.getThis)

Issue: SPR-15651
This commit is contained in:
Juergen Hoeller
2017-06-12 22:54:18 +02:00
parent 233c15b80e
commit 47ec966757
8 changed files with 67 additions and 47 deletions

View File

@@ -35,6 +35,7 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.Order;
import org.springframework.lang.Nullable;
import org.springframework.tests.TimeStamped;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.interceptor.NopInterceptor;
@@ -369,6 +370,16 @@ public class ProxyFactoryTests {
assertSame(proxy1, list.get(1));
}
@Test
public void testInterceptorWithoutJoinpoint() {
final TestBean target = new TestBean("tb");
ITestBean proxy = ProxyFactory.getProxy(ITestBean.class, (MethodInterceptor) invocation -> {
assertNull(invocation.getThis());
return invocation.getMethod().invoke(target, invocation.getArguments());
});
assertEquals("tb", proxy.getName());
}
@SuppressWarnings("serial")
private static class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor