Skip to content

Commit

Permalink
Update MicroProfile Config to 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Mar 6, 2024
1 parent 8348ef1 commit 72c87ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<hdrhistogram.version>2.1.12</hdrhistogram.version><!-- keep in sync with micrometer -->
<google-auth.version>0.22.0</google-auth.version>
<graphql-java.version>21.1</graphql-java.version> <!-- keep in sync with smallrye-graphql -->
<microprofile-config-api.version>3.0.3</microprofile-config-api.version>
<microprofile-config-api.version>3.1</microprofile-config-api.version>
<microprofile-health-api.version>4.0.1</microprofile-health-api.version>
<microprofile-metrics-api.version>4.0.1</microprofile-metrics-api.version>
<microprofile-context-propagation.version>1.3</microprofile-context-propagation.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package io.quarkus.arc.runtime;

import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.function.Supplier;

import jakarta.annotation.Priority;
import jakarta.enterprise.inject.spi.DeploymentException;
import jakarta.enterprise.inject.spi.InjectionPoint;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;
Expand All @@ -17,6 +26,7 @@
import io.quarkus.arc.impl.InjectionPointProvider;
import io.quarkus.runtime.ExecutionMode;
import io.quarkus.runtime.annotations.StaticInitSafe;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.smallrye.config.SmallRyeConfig;
import io.smallrye.config.inject.ConfigProducer;

Expand Down Expand Up @@ -69,7 +79,21 @@ static void recordConfigValue(InjectionPoint injectionPoint, ConfigStaticInitVal
value = getDefaultValue(injectionPoint, configProperty);
}
if (value == null) {
LOG.debugf("No config value found for %s - recording <null> value", propertyName);
Type type = injectionPoint.getType();
// To validate injection points of configuration in observer methods
if (type instanceof Class && org.eclipse.microprofile.config.ConfigValue.class.isAssignableFrom((Class<?>) type)
|| type instanceof Class && OptionalInt.class.isAssignableFrom((Class<?>) type)
|| type instanceof Class && OptionalLong.class.isAssignableFrom((Class<?>) type)
|| type instanceof Class && OptionalDouble.class.isAssignableFrom((Class<?>) type)
|| type instanceof ParameterizedType
&& (Optional.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())
|| Provider.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())
|| Supplier.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType()))) {
LOG.debugf("No config value found for %s - recording <null> value", propertyName);
} else {
throw new DeploymentException(
new ConfigurationException("Failed to load config value of type " + type + " for: " + propertyName));
}
}
if (configValues == null) {
configValues = Arc.container().instance(ConfigStaticInitValues.class).get();
Expand Down
6 changes: 1 addition & 5 deletions tcks/microprofile-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>Quarkus - TCK - MicroProfile Config</name>

<properties>
<microprofile-config-tck.version>3.0.3</microprofile-config-tck.version>
<microprofile-config-tck.version>3.1</microprofile-config-tck.version>
</properties>

<build>
Expand Down Expand Up @@ -43,10 +43,6 @@
<systemPropertyVariables>
<!-- Disable quarkus optimization -->
<quarkus.arc.remove-unused-beans>false</quarkus.arc.remove-unused-beans>
<!-- 1. There is a bug in TCK: -->
<!-- https://github.com/eclipse/microprofile-config/issues/543 -->
<!-- 2. After transformation we get a ClassCastException which is very likely caused by a class loading problem in our Arquillian adapter -->
<quarkus.arc.transform-unproxyable-classes>false</quarkus.arc.transform-unproxyable-classes>
</systemPropertyVariables>
<!-- This workaround allows us to run a single test using
the "test" system property -->
Expand Down

0 comments on commit 72c87ef

Please sign in to comment.