You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/12/30 12:18:10 UTC

[GitHub] [skywalking] xuanyu66 commented on issue #6105: agent's switch at runtime

xuanyu66 commented on issue #6105:
URL: https://github.com/apache/skywalking/issues/6105#issuecomment-752505368


   we will not invoke all method in the interceptor
   ```
   public Object intercept(@This Object obj, @AllArguments Object[] allArguments, @SuperCall Callable<?> zuper,
           @Origin Method method) throws Throwable {
           EnhancedInstance targetObject = (EnhancedInstance) obj;
    
           MethodInterceptResult result = new MethodInterceptResult();
           try {
               if(tracingEnable) {
                      interceptor.beforeMethod(targetObject, method, allArguments, method.getParameterTypes(), result);
               }
           } catch (Throwable t) {
               LOGGER.error(t, "class[{}] before method[{}] intercept failure", obj.getClass(), method.getName());
           }
    
           Object ret = null;
           try {
               if (!result.isContinue()) {
                   ret = result._ret();
               } else {
                   ret = zuper.call();
               }
           } catch (Throwable t) {
               try {
                   if(tracingEnable) {
                           interceptor.handleMethodException(targetObject, method, allArguments, method.getParameterTypes(), t);
                   }
               } catch (Throwable t2) {
                   LOGGER.error(t2, "class[{}] handle method[{}] exception failure", obj.getClass(), method.getName());
               }
               throw t;
           } finally {
               try {
                   if(tracingEnable) {
                         ret = interceptor.afterMethod(targetObject, method, allArguments, method.getParameterTypes(), ret);
                   }
               } catch (Throwable t) {
                   LOGGER.error(t, "class[{}] after method[{}] intercept failure", obj.getClass(), method.getName());
               }
           }
           return ret;
       }
   ```
   if tracingEnable == false, it only invoke the origin call ref, which would'nt cause memory leak.
   And tracingEnable is a Immutable copy value.


----------------------------------------------------------------
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:
users@infra.apache.org