From 930f8c5d886e84828b809aa33aaa3d723736ba26 Mon Sep 17 00:00:00 2001 From: puppy4c Date: Sat, 18 Jan 2025 15:36:18 +0800 Subject: [PATCH] Cache Interceptor signature result --- src/main/java/org/apache/ibatis/plugin/Plugin.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/apache/ibatis/plugin/Plugin.java b/src/main/java/org/apache/ibatis/plugin/Plugin.java index feae8724c84..ad0cb5b430e 100644 --- a/src/main/java/org/apache/ibatis/plugin/Plugin.java +++ b/src/main/java/org/apache/ibatis/plugin/Plugin.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import org.apache.ibatis.reflection.ExceptionUtil; @@ -30,6 +31,8 @@ */ public class Plugin implements InvocationHandler { + private static final Map, Map, Set>> signatureMapCache = new ConcurrentHashMap<>(); + private final Object target; private final Interceptor interceptor; private final Map, Set> signatureMap; @@ -64,6 +67,10 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl } private static Map, Set> getSignatureMap(Interceptor interceptor) { + return signatureMapCache.computeIfAbsent(interceptor.getClass(), (clazz) -> createSignatureMap(interceptor)); + } + + private static Map, Set> createSignatureMap(Interceptor interceptor) { Intercepts interceptsAnnotation = interceptor.getClass().getAnnotation(Intercepts.class); // issue #251 if (interceptsAnnotation == null) {