Skip to content

Commit

Permalink
[#11153] Fix interceptor holder lazyloading
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehong-kim committed Jun 17, 2024
1 parent ea6b21f commit 010cfd6
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@

import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor;
import com.navercorp.pinpoint.bootstrap.interceptor.Interceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.LoggingInterceptor;
import com.navercorp.pinpoint.profiler.instrument.ScopeInfo;
import com.navercorp.pinpoint.profiler.interceptor.factory.InterceptorFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.function.Supplier;

public class InterceptorLazyLoadingSupplier implements Supplier<Interceptor> {
private static final LoggingInterceptor LOGGING_INTERCEPTOR = new LoggingInterceptor("com.navercorp.pinpoint.profiler.interceptor.LAZYLOADING");
private final Logger logger = LogManager.getLogger(this.getClass());

private final InterceptorFactory factory;
private final Class<?> interceptorClass;
private final Object[] providedArguments;
Expand All @@ -40,7 +46,18 @@ public InterceptorLazyLoadingSupplier(InterceptorFactory factory, Class<?> inter

@Override
public Interceptor get() {
Interceptor interceptor = factory.newInterceptor(interceptorClass, providedArguments, scopeInfo, methodDescriptor);
Interceptor interceptor = null;
try {
interceptor = factory.newInterceptor(interceptorClass, providedArguments, scopeInfo, methodDescriptor);
} catch (Throwable t) {
logger.warn("Failed to new interceptor, interceptor={}", interceptorClass.getName(), t);
}

if (interceptor == null) {
// defense
return LOGGING_INTERCEPTOR;
}
return interceptor;

}
}

0 comments on commit 010cfd6

Please sign in to comment.