From 0d3de92fc18ba86b4bd154d0b32ca8aec2a5c234 Mon Sep 17 00:00:00 2001 From: Ludovic DEHON Date: Wed, 6 Jul 2022 07:58:26 +0200 Subject: [PATCH] fix(core): plugins validation failed with micronaut update --- .../kestra/core/contexts/KestraValidator.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/core/src/main/java/io/kestra/core/contexts/KestraValidator.java b/core/src/main/java/io/kestra/core/contexts/KestraValidator.java index e569a089643..54c615ec4d2 100644 --- a/core/src/main/java/io/kestra/core/contexts/KestraValidator.java +++ b/core/src/main/java/io/kestra/core/contexts/KestraValidator.java @@ -16,9 +16,7 @@ import io.kestra.core.plugins.PluginRegistry; import io.kestra.core.plugins.RegisteredPlugin; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; +import java.util.*; @Singleton @Replaces(DefaultValidator.class) @@ -31,8 +29,7 @@ protected KestraValidator(@NonNull ValidatorConfiguration configuration) { super(configuration); } - protected @Nullable - BeanIntrospection getBeanIntrospection(@NonNull Object object) { + protected @Nullable BeanIntrospection getBeanIntrospection(@NonNull Object object) { //noinspection ConstantConditions if (object == null) { return null; @@ -102,18 +99,13 @@ private Map> getIntrospections() { if (pluginRegistry != null) { for (RegisteredPlugin registeredPlugin : pluginRegistry.getPlugins()) { - SoftServiceLoader services = SoftServiceLoader.load(BeanIntrospectionReference.class, registeredPlugin.getClassLoader()); - - for (ServiceDefinition service : services) { - if (service.isPresent()) { - BeanIntrospectionReference ref = service.load(); - ((Map) introspectionMap).put(ref.getName(), ref); - } else if (log.isDebugEnabled()) { - log.debug( - "BeanIntrospection {} not loaded since associated bean is not present on the classpath", - service.getName() - ); - } + SoftServiceLoader loader = SoftServiceLoader.load(BeanIntrospectionReference.class, registeredPlugin.getClassLoader()); + + List definitions = new ArrayList<>(100); + loader.collectAll(definitions); + + for (BeanIntrospectionReference definition : definitions) { + ((Map) introspectionMap).put(definition.getName(), definition); } } }