wu-sheng commented on a change in pull request #6973:
URL: https://github.com/apache/skywalking/pull/6973#discussion_r636849434



##########
File path: 
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/v5/InvokeInterceptor.java
##########
@@ -17,48 +17,47 @@
 
 package org.apache.skywalking.apm.plugin.spring.mvc.v5;
 
-import java.lang.reflect.Method;
 import org.apache.skywalking.apm.agent.core.context.ContextManager;
 import org.apache.skywalking.apm.agent.core.context.tag.Tags;
 import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
 import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import 
org.apache.skywalking.apm.plugin.spring.mvc.commons.ReactiveRequestHolder;
-import 
org.apache.skywalking.apm.plugin.spring.mvc.commons.ReactiveResponseHolder;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2.InstanceMethodsAroundInterceptorV2;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2.MethodInvocationContext;
 import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpResponse;
 import org.springframework.web.server.ServerWebExchange;
 import reactor.core.publisher.Mono;
 
+import java.lang.reflect.Method;
+
+import static 
org.apache.skywalking.apm.plugin.spring.mvc.commons.Constants.REACTIVE_ASYNC_SPAN_IN_RUNTIME_CONTEXT;
 import static 
org.apache.skywalking.apm.plugin.spring.mvc.commons.Constants.REQUEST_KEY_IN_RUNTIME_CONTEXT;
 import static 
org.apache.skywalking.apm.plugin.spring.mvc.commons.Constants.RESPONSE_KEY_IN_RUNTIME_CONTEXT;
 
-public class InvokeInterceptor implements InstanceMethodsAroundInterceptor {
+public class InvokeInterceptor implements InstanceMethodsAroundInterceptorV2 {
     @Override
-    public void beforeMethod(final EnhancedInstance objInst,
-                             final Method method,
-                             final Object[] allArguments,
-                             final Class<?>[] argumentsTypes,
-                             final MethodInterceptResult result) throws 
Throwable {
+    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] 
allArguments, Class<?>[] argumentsTypes, MethodInvocationContext context) 
throws Throwable {
         ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
-        final ReactiveResponseHolder responseHolder = new 
ReactiveResponseHolder(exchange.getResponse());
+        final ServerHttpResponse response = exchange.getResponse();
+        AbstractSpan[] ref = new AbstractSpan[1];
         ContextManager.getRuntimeContext()
-                .put(RESPONSE_KEY_IN_RUNTIME_CONTEXT, responseHolder);
+                .put(REACTIVE_ASYNC_SPAN_IN_RUNTIME_CONTEXT, ref);
         ContextManager.getRuntimeContext()
-                .put(REQUEST_KEY_IN_RUNTIME_CONTEXT, new 
ReactiveRequestHolder(exchange.getRequest()));
-        objInst.setSkyWalkingDynamicField(responseHolder);
+                .put(RESPONSE_KEY_IN_RUNTIME_CONTEXT, response);
+        ContextManager.getRuntimeContext()

Review comment:
       Don't use duplicated `ContextManager.getRuntimeContext()`




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to