You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "lujiajing1126 (via GitHub)" <gi...@apache.org> on 2025/04/30 08:44:58 UTC

Re: [PR] Fix CreateAopProxyInterceptor in the Spring core-patch indeed changes the implementation of the Spring AOP proxy [skywalking-java]

lujiajing1126 commented on code in PR #739:
URL: https://github.com/apache/skywalking-java/pull/739#discussion_r2068184158


##########
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/test/java/org/apache/skywalking/apm/plugin/spring/patch/CreateAopProxyInterceptorTest.java:
##########
@@ -48,18 +49,69 @@ public void setUp() {
     }
 
     @Test
-    public void testInterceptNormalObject() throws Throwable {
-        doReturn(Object.class).when(advisedSupport).getTargetClass();
+    public void testInterceptClassImplementsNoInterfaces() throws Throwable {
+        // doReturn(Object.class).when(advisedSupport).getTargetClass();
+        // doReturn(Object.class.getInterfaces()).when(advisedSupport).getProxiedInterfaces();
+        assertThat(true, is(interceptor.afterMethod(enhancedInstance, null, new Object[] {advisedSupport}, new Class[] {Object.class}, true)));
+    }
+
+    @Test
+    public void testInterceptClassImplementsUserSuppliedInterface() throws Throwable {
+        doReturn(MockClassImplementsUserSuppliedInterface.class).when(advisedSupport).getTargetClass();
+        doReturn(MockClassImplementsUserSuppliedInterface.class.getInterfaces()).when(advisedSupport).getProxiedInterfaces();
         assertThat(false, is(interceptor.afterMethod(enhancedInstance, null, new Object[] {advisedSupport}, new Class[] {Object.class}, false)));
     }
 
     @Test
-    public void testInterceptEnhanceInstanceObject() throws Throwable {
-        doReturn(MockClass.class).when(advisedSupport).getTargetClass();
+    public void testInterceptClassImplementsSpringProxy() throws Throwable {
+        // doReturn(MockClassImplementsSpringProxy.class).when(advisedSupport).getTargetClass();
+        // doReturn(MockClassImplementsSpringProxy.class.getInterfaces()).when(advisedSupport).getProxiedInterfaces();
+        assertThat(true, is(interceptor.afterMethod(enhancedInstance, null, new Object[] {advisedSupport}, new Class[] {Object.class}, true)));
+    }
+
+    @Test
+    public void testInterceptClassImplementsEnhancedInstance() throws Throwable {
+        doReturn(MockClassImplementsEnhancedInstance.class).when(advisedSupport).getTargetClass();
+        doReturn(MockClassImplementsEnhancedInstance.class.getInterfaces()).when(advisedSupport).getProxiedInterfaces();
         assertThat(true, is(interceptor.afterMethod(enhancedInstance, null, new Object[] {advisedSupport}, new Class[] {Object.class}, false)));

Review Comment:
   https://stackoverflow.com/questions/45124660/the-bean-could-not-be-injected-as-a-type-because-it-is-a-jdk-dynamic-proxy-tha
   
   According to the answer in this SO thread, we basically should not expect classes that both use `@Transactional` annotation and being enhanced by SkyWalking Agent to use JDK Proxy.
   
   We are facing startup failures after upgrading to SkyWalking 9.4.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org