From c02e6257ad5245ac0793254a281580144c001293 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Wed, 4 Oct 2023 11:23:46 +0200 Subject: [PATCH] Config: remove the warning for ConfigInjectionStaticInitBuildItem - deprecate ConfigInjectionStaticInitBuildItem --- .../arc/deployment/ConfigBuildStep.java | 68 ------------------- .../ConfigInjectionStaticInitBuildItem.java | 5 ++ .../deployment/ResteasyCommonProcessor.java | 6 -- .../deployment/UndertowBuildStep.java | 6 -- 4 files changed, 5 insertions(+), 80 deletions(-) diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java index f84a334724aa7c..bffd54d9b832c4 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java @@ -30,7 +30,6 @@ import jakarta.enterprise.context.Dependent; import jakarta.enterprise.inject.CreationException; -import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigValue; import org.eclipse.microprofile.config.inject.ConfigProperties; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -42,10 +41,8 @@ import org.jboss.jandex.DotName; import org.jboss.jandex.FieldInfo; import org.jboss.jandex.MethodInfo; -import org.jboss.jandex.ParameterizedType; import org.jboss.jandex.Type; import org.jboss.jandex.Type.Kind; -import org.jboss.logging.Logger; import io.quarkus.arc.Unremovable; import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem.BeanConfiguratorBuildItem; @@ -67,7 +64,6 @@ import io.quarkus.deployment.builditem.ConfigPropertiesBuildItem; import io.quarkus.deployment.builditem.ConfigurationBuildItem; import io.quarkus.deployment.builditem.GeneratedClassBuildItem; -import io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.configuration.definition.RootDefinition; import io.quarkus.deployment.recording.RecorderContext; @@ -80,14 +76,11 @@ * MicroProfile Config related build steps. */ public class ConfigBuildStep { - private static final Logger LOGGER = Logger.getLogger(ConfigBuildStep.class.getName()); - private static final DotName MP_CONFIG = DotName.createSimple(Config.class.getName()); static final DotName MP_CONFIG_PROPERTY_NAME = DotName.createSimple(ConfigProperty.class.getName()); private static final DotName MP_CONFIG_PROPERTIES_NAME = DotName.createSimple(ConfigProperties.class.getName()); private static final DotName MP_CONFIG_VALUE_NAME = DotName.createSimple(ConfigValue.class.getName()); - private static final DotName SR_CONFIG = DotName.createSimple(io.smallrye.config.SmallRyeConfig.class.getName()); private static final DotName SR_CONFIG_VALUE_NAME = DotName.createSimple(io.smallrye.config.ConfigValue.class.getName()); private static final DotName MAP_NAME = DotName.createSimple(Map.class.getName()); @@ -474,67 +467,6 @@ void validateConfigPropertiesInjectionPoints( toRegister.forEach(configProperties::produce); } - @BuildStep - void warnStaticInitInjectionPoints( - CombinedIndexBuildItem indexBuildItem, - ValidationPhaseBuildItem validationPhase, - List configClasses, - List configInjectionStaticInit, - BuildProducer runTimeConfigurationDefault) { - - // Add here annotated classes that are initialized during static init - Set declaringClassCandidates = configInjectionStaticInit.stream() - .map(ConfigInjectionStaticInitBuildItem::getDeclaringCandidate).collect(toSet()); - - Set configClassesTypes = configClasses.stream().map(ConfigClassBuildItem::getTypes).flatMap(Collection::stream) - .collect(toSet()); - - for (InjectionPointInfo injectionPoint : validationPhase.getContext().getInjectionPoints()) { - if (injectionPoint.getType().name().equals(DotNames.INSTANCE)) { - continue; - } - - Type type = Type.create(injectionPoint.getRequiredType().name(), Type.Kind.CLASS); - DotName injectionTypeName = null; - if (type.name().equals(MP_CONFIG) || type.name().equals(SR_CONFIG)) { - injectionTypeName = type.name(); - } else if (injectionPoint.getRequiredQualifier(MP_CONFIG_PROPERTY_NAME) != null) { - injectionTypeName = MP_CONFIG_PROPERTY_NAME; - } else if (configClassesTypes.contains(type)) { - injectionTypeName = type.name(); - } - - if (injectionTypeName != null) { - AnnotationTarget target = injectionPoint.getTarget(); - if (FIELD.equals(target.kind())) { - FieldInfo field = target.asField(); - ClassInfo declaringClass = field.declaringClass(); - Map> annotationsMap = declaringClass.annotationsMap(); - for (DotName declaringClassCandidate : declaringClassCandidates) { - List annotationInstances = annotationsMap.get(declaringClassCandidate); - if (annotationInstances != null && annotationInstances.size() == 1) { - AnnotationInstance annotationInstance = annotationInstances.get(0); - if (annotationInstance.target().equals(declaringClass)) { - LOGGER.warn("Directly injecting a " + - injectionTypeName + - " into a " + - declaringClassCandidate + - " may lead to unexpected results. To ensure proper results, please " + - "change the type of the field to " + - ParameterizedType.create(DotNames.INSTANCE, new Type[] { type }, null) + - ". Offending field is '" + - field.name() + - "' of class '" + - field.declaringClass() + - "'"); - } - } - } - } - } - } - } - @BuildStep @Record(RUNTIME_INIT) void registerConfigClasses( diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java index efb1919e33b024..78be1302d7c80f 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java @@ -4,6 +4,11 @@ import io.quarkus.builder.item.MultiBuildItem; +/** + * + * @deprecated This build item is not used anymore + */ +@Deprecated(forRemoval = true) public final class ConfigInjectionStaticInitBuildItem extends MultiBuildItem { private final DotName declaringCandidate; diff --git a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java index de8247f62696b0..b78d5eec48b581 100644 --- a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java +++ b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java @@ -43,7 +43,6 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem; import io.quarkus.arc.deployment.BeanContainerBuildItem; -import io.quarkus.arc.deployment.ConfigInjectionStaticInitBuildItem; import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.processor.DotNames; import io.quarkus.deployment.Capabilities; @@ -181,11 +180,6 @@ ResteasyInjectionReadyBuildItem setupResteasyInjection( return new ResteasyInjectionReadyBuildItem(injectorFactory); } - @BuildStep - ConfigInjectionStaticInitBuildItem configInjectionStaticInitProvider() { - return new ConfigInjectionStaticInitBuildItem(ResteasyDotNames.PROVIDER); - } - @BuildStep JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer reflectiveClass, CombinedIndexBuildItem indexBuildItem, diff --git a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java index 06fd8dd5d71698..415204b0d4fc29 100644 --- a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java +++ b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java @@ -81,7 +81,6 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; import io.quarkus.arc.deployment.BeanContainerBuildItem; -import io.quarkus.arc.deployment.ConfigInjectionStaticInitBuildItem; import io.quarkus.arc.deployment.ContextRegistrationPhaseBuildItem; import io.quarkus.arc.deployment.ContextRegistrationPhaseBuildItem.ContextConfiguratorBuildItem; import io.quarkus.arc.deployment.CustomScopeBuildItem; @@ -685,11 +684,6 @@ SyntheticBeanBuildItem servletContextBean( .supplier(recorder.servletContextSupplier()).done(); } - @BuildStep - ConfigInjectionStaticInitBuildItem configInjectionStaticInitAnnotations() { - return new ConfigInjectionStaticInitBuildItem(WEB_FILTER); - } - /** * Process a single index. *