From 7672e6f50ed64687ca6b1a06eef946ddd1706b28 Mon Sep 17 00:00:00 2001 From: Jaehong-Kim Date: Mon, 17 Jun 2024 11:26:54 +0900 Subject: [PATCH] [#11153] Fix interceptor holder lazyloading --- .../InterceptorLazyLoadingSupplier.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorLazyLoadingSupplier.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorLazyLoadingSupplier.java index 897c381e93d6..376528f30e79 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorLazyLoadingSupplier.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorLazyLoadingSupplier.java @@ -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 { + 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; @@ -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; + } }