From 404c5edb094bf513d011a5310768005748f9e2be Mon Sep 17 00:00:00 2001 From: crazyhzm Date: Sun, 4 Feb 2024 17:43:31 +0800 Subject: [PATCH] Fix ut Signed-off-by: crazyhzm --- .../dubbo/config/spring6/utils/AotUtils.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dubbo-config/dubbo-config-spring6/src/main/java/org/apache/dubbo/config/spring6/utils/AotUtils.java b/dubbo-config/dubbo-config-spring6/src/main/java/org/apache/dubbo/config/spring6/utils/AotUtils.java index 1d5c86b2b4b..c96d4c33c80 100644 --- a/dubbo-config/dubbo-config-spring6/src/main/java/org/apache/dubbo/config/spring6/utils/AotUtils.java +++ b/dubbo-config/dubbo-config-spring6/src/main/java/org/apache/dubbo/config/spring6/utils/AotUtils.java @@ -29,20 +29,21 @@ public class AotUtils { - private static final Set> serializationTypeCache = new LinkedHashSet<>(); - private AotUtils() {} public static void registerSerializationForService(Class serviceType, RuntimeHints hints) { + Set> serializationTypeCache = new LinkedHashSet<>(); Arrays.stream(serviceType.getMethods()).forEach((method) -> { Arrays.stream(method.getParameterTypes()) - .forEach((parameterType) -> registerSerializationType(parameterType, hints)); + .forEach( + (parameterType) -> registerSerializationType(parameterType, hints, serializationTypeCache)); - registerSerializationType(method.getReturnType(), hints); + registerSerializationType(method.getReturnType(), hints, serializationTypeCache); }); } - private static void registerSerializationType(Class registerType, RuntimeHints hints) { + private static void registerSerializationType( + Class registerType, RuntimeHints hints, Set> serializationTypeCache) { if (isPrimitive(registerType)) { hints.serialization().registerType(TypeReference.of(ClassUtils.getBoxedClass(registerType))); serializationTypeCache.add(registerType); @@ -53,12 +54,12 @@ private static void registerSerializationType(Class registerType, RuntimeHint Arrays.stream(registerType.getDeclaredFields()).forEach((field -> { if (!serializationTypeCache.contains(field.getType())) { - registerSerializationType(field.getType(), hints); + registerSerializationType(field.getType(), hints, serializationTypeCache); serializationTypeCache.add(field.getType()); } })); - registerSerializationType(registerType.getSuperclass(), hints); + registerSerializationType(registerType.getSuperclass(), hints, serializationTypeCache); } } }