From 9e89f4d6dea15a3d5bd9387d228e4e4603540794 Mon Sep 17 00:00:00 2001 From: lucca Date: Thu, 25 May 2023 15:12:46 +0800 Subject: [PATCH] Refactor ThreadPoolInstance Registry to ThreadPoolRegistry. --- .../common/support/SpringThreadPoolRegisterSupport.java | 2 +- .../ThreadPoolExecutorConstructorMethodInterceptor.java | 2 +- .../cn/hippo4j/common/executor/ThreadPoolRegistry.java | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/agent/hippo4j-agent-plugin/spring-plugins/spring-plugin-common/src/main/java/cn/hippo4j/agent/plugin/spring/common/support/SpringThreadPoolRegisterSupport.java b/agent/hippo4j-agent-plugin/spring-plugins/spring-plugin-common/src/main/java/cn/hippo4j/agent/plugin/spring/common/support/SpringThreadPoolRegisterSupport.java index ec86efe2..b2d08574 100644 --- a/agent/hippo4j-agent-plugin/spring-plugins/spring-plugin-common/src/main/java/cn/hippo4j/agent/plugin/spring/common/support/SpringThreadPoolRegisterSupport.java +++ b/agent/hippo4j-agent-plugin/spring-plugins/spring-plugin-common/src/main/java/cn/hippo4j/agent/plugin/spring/common/support/SpringThreadPoolRegisterSupport.java @@ -41,7 +41,7 @@ public class SpringThreadPoolRegisterSupport { private static final Logger LOGGER = LoggerFactory.getLogger(SpringThreadPoolRegisterSupport.class); public static void registerThreadPoolInstances(ApplicationContext context) { - Map> referencedClassMap = ThreadPoolRegistry.getReferencedClassMap(); + Map> referencedClassMap = ThreadPoolRegistry.REFERENCED_CLASS_MAP; for (Map.Entry> entry : referencedClassMap.entrySet()) { ThreadPoolExecutor enhancedInstance = entry.getKey(); Class declaredClass = entry.getValue(); diff --git a/agent/hippo4j-agent-plugin/threadpool-plugin/src/main/java/cn/hippo4j/agent/plugin/thread/pool/interceptor/ThreadPoolExecutorConstructorMethodInterceptor.java b/agent/hippo4j-agent-plugin/threadpool-plugin/src/main/java/cn/hippo4j/agent/plugin/thread/pool/interceptor/ThreadPoolExecutorConstructorMethodInterceptor.java index d85b0bdc..343d05d2 100644 --- a/agent/hippo4j-agent-plugin/threadpool-plugin/src/main/java/cn/hippo4j/agent/plugin/thread/pool/interceptor/ThreadPoolExecutorConstructorMethodInterceptor.java +++ b/agent/hippo4j-agent-plugin/threadpool-plugin/src/main/java/cn/hippo4j/agent/plugin/thread/pool/interceptor/ThreadPoolExecutorConstructorMethodInterceptor.java @@ -52,7 +52,7 @@ public class ThreadPoolExecutorConstructorMethodInterceptor implements InstanceC StackTraceElement declaredClassStackTraceElement = stackTraceElements.get(0); String declaredClassName = declaredClassStackTraceElement.getClassName(); Class declaredClass = Thread.currentThread().getContextClassLoader().loadClass(declaredClassName); - ThreadPoolRegistry.putReferencedClass((ThreadPoolExecutor) objInst, declaredClass); + ThreadPoolRegistry.REFERENCED_CLASS_MAP.put((ThreadPoolExecutor) objInst, declaredClass); } private List getStackTraceElements() { diff --git a/infra/common/src/main/java/cn/hippo4j/common/executor/ThreadPoolRegistry.java b/infra/common/src/main/java/cn/hippo4j/common/executor/ThreadPoolRegistry.java index dbc91917..bff59cf0 100644 --- a/infra/common/src/main/java/cn/hippo4j/common/executor/ThreadPoolRegistry.java +++ b/infra/common/src/main/java/cn/hippo4j/common/executor/ThreadPoolRegistry.java @@ -49,12 +49,4 @@ public class ThreadPoolRegistry { public static Map> getReferencedClassMap() { return REFERENCED_CLASS_MAP; } - - public static void putReferencedClass(ThreadPoolExecutor executor, Class referencedClass) { - REFERENCED_CLASS_MAP.put(executor, referencedClass); - } - - public static Class getReferencedClass(ThreadPoolExecutor executor) { - return REFERENCED_CLASS_MAP.get(executor); - } }