Skip to content

Commit

Permalink
Merge pull request #25127 from mkouba/issue-25123
Browse files Browse the repository at this point in the history
MP Config - fix programmatic lookup of custom type config property
  • Loading branch information
mkouba authored Apr 25, 2022
2 parents 6d057ee + 0274b7a commit 6a81f60
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void registerCustomConfigBeanTypes(BeanDiscoveryFinishedBuildItem beanDiscovery,
AnnotationInstance configProperty = injectionPoint.getRequiredQualifier(MP_CONFIG_PROPERTY_NAME);
if (configProperty != null) {
// Register a custom bean for injection points that are not handled by ConfigProducer
Type injectedType = injectionPoint.getType();
Type injectedType = injectionPoint.getRequiredType();
if (!isHandledByProducers(injectedType)) {
customBeanTypes.add(injectedType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Provider;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.shrinkwrap.api.asset.StringAsset;
Expand All @@ -17,15 +18,16 @@ public class ConfigImplicitConverterTest {
@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(Configured.class)
.addAsResource(new StringAsset("foo=1"), "application.properties"));
.addClasses(Configured.class, Foo.class, Bar.class)
.addAsResource(new StringAsset("foo=1\nbar=1"), "application.properties"));

@Inject
Configured configured;

@Test
public void testFoo() {
assertEquals("1", configured.getFooValue());
assertEquals("1", configured.getBarProviderValue());
}

@ApplicationScoped
Expand All @@ -35,9 +37,17 @@ static class Configured {
@ConfigProperty(name = "foo")
Foo foo;

@ConfigProperty(name = "bar")
Provider<Bar> barProvider;

String getFooValue() {
return foo != null ? foo.value : null;
}

String getBarProviderValue() {
return barProvider.get().value;
}

}

public static class Foo {
Expand All @@ -50,4 +60,14 @@ public Foo(String value) {

}

public static class Bar {

String value;

public Bar(String value) {
this.value = value;
}

}

}

0 comments on commit 6a81f60

Please sign in to comment.