Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP Config - fix programmatic lookup of custom type config property #25127

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}

}