From a1d34fa0cc2be202f5bd2badfdee3c06fab60455 Mon Sep 17 00:00:00 2001 From: Andriy Dmytruk <80816836+andriy-dmytruk@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:40:58 -0500 Subject: [PATCH] Fix for ServiceLoaderFeature (#11402) ServiceLoaderFeature did not include all the @Requires annotations, as some were added with the @Requirements. I included such in the native-image beforeAnalysis. As an example, this fixes the usage of condition in io.micronaut.configuration.metrics.binder.web.ClientRequestMetricRegistryFilter. --- .../io/micronaut/core/io/service/ServiceLoaderFeature.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/java/io/micronaut/core/io/service/ServiceLoaderFeature.java b/core/src/main/java/io/micronaut/core/io/service/ServiceLoaderFeature.java index 6a7f71a9c5f..86d2bc67667 100644 --- a/core/src/main/java/io/micronaut/core/io/service/ServiceLoaderFeature.java +++ b/core/src/main/java/io/micronaut/core/io/service/ServiceLoaderFeature.java @@ -89,6 +89,12 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { } Class beanType = beanInfo.getBeanType(); List> values = beanInfo.getAnnotationMetadata().getAnnotationValuesByName("io.micronaut.context.annotation.Requires"); + if (values.isEmpty()) { + AnnotationValue requirements = beanInfo.getAnnotationMetadata().getAnnotation("io.micronaut.context.annotation.Requirements"); + if (requirements != null) { + values = requirements.getAnnotations("value"); + } + } if (!values.isEmpty()) { for (AnnotationValue value : values) { String[] classNames = EMPTY_STRING_ARRAY;