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); } } }