Skip to content
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 @@ -96,11 +96,8 @@ void analyzeConfigPropertyInjectionPoints(BeanRegistrationPhaseBuildItem beanReg
// No need to validate properties with default values
continue;
}
String propertyType = requiredType.name().toString();
if (requiredType.kind() != Kind.ARRAY && requiredType.kind() != Kind.PRIMITIVE) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, propertyType));
}
configProperties.produce(new ConfigPropertyBuildItem(propertyName, propertyType));

configProperties.produce(new ConfigPropertyBuildItem(propertyName, requiredType));
}
}

Expand All @@ -127,12 +124,21 @@ AutoInjectAnnotationBuildItem autoInjectConfigProperty() {
@BuildStep
@Record(RUNTIME_INIT)
void validateConfigProperties(ConfigRecorder recorder, List<ConfigPropertyBuildItem> configProperties,
BeanContainerBuildItem beanContainer) {
BeanContainerBuildItem beanContainer, BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
// IMPL NOTE: we do depend on BeanContainerBuildItem to make sure that the BeanDeploymentValidator finished its processing

// the non-primitive types need to be registered for reflection since Class.forName is used at runtime to load the class
for (ConfigPropertyBuildItem item : configProperties) {
Type requiredType = item.getPropertyType();
String propertyType = requiredType.name().toString();
if (requiredType.kind() != Kind.ARRAY && requiredType.kind() != Kind.PRIMITIVE) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, propertyType));
}
}

Map<String, Set<String>> propNamesToClasses = configProperties.stream().collect(
groupingBy(ConfigPropertyBuildItem::getPropertyName,
mapping(ConfigPropertyBuildItem::getPropertyType, toSet())));
mapping(c -> c.getPropertyType().name().toString(), toSet())));
recorder.validateConfigProperties(propNamesToClasses);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.arc.deployment;

import org.jboss.jandex.Type;

import io.quarkus.builder.item.MultiBuildItem;

/**
Expand All @@ -9,9 +11,9 @@ public final class ConfigPropertyBuildItem extends MultiBuildItem {

private final String propertyName;

private final String propertyType;
private final Type propertyType;

public ConfigPropertyBuildItem(String propertyName, String propertyType) {
public ConfigPropertyBuildItem(String propertyName, Type propertyType) {
this.propertyName = propertyName;
this.propertyType = propertyType;
}
Expand All @@ -20,7 +22,7 @@ public String getPropertyName() {
return propertyName;
}

public String getPropertyType() {
public Type getPropertyType() {
return propertyType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private static ResultHandle populateConfigObject(ClassLoader classLoader, ClassI

}
configPropertyBuildItemCandidates
.add(new ConfigPropertyBuildItemCandidate(field.name(), fullConfigName, fieldTypeStr));
.add(new ConfigPropertyBuildItemCandidate(field.name(), fullConfigName, fieldType));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.quarkus.arc.deployment.configproperties;

import org.jboss.jandex.Type;

public class ConfigPropertyBuildItemCandidate {

private final String fieldName;

private final String configPropertyName;

private final String configPropertyType;
private final Type configPropertyType;

public ConfigPropertyBuildItemCandidate(String fieldName, String configPropertyName, String configPropertyType) {
public ConfigPropertyBuildItemCandidate(String fieldName, String configPropertyName, Type configPropertyType) {
this.fieldName = fieldName;
this.configPropertyName = configPropertyName;
this.configPropertyType = configPropertyType;
Expand All @@ -22,7 +24,7 @@ public String getConfigPropertyName() {
return configPropertyName;
}

public String getConfigPropertyType() {
public Type getConfigPropertyType() {
return configPropertyType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static String generateImplementationForInterfaceConfigProperties(ClassInfo origi
methodCreator.returnValue(value);
if (defaultValueStr == null || ConfigProperty.UNCONFIGURED_VALUE.equals(defaultValueStr)) {
configProperties
.produce(new ConfigPropertyBuildItem(fullConfigName, returnType.name().toString()));
.produce(new ConfigPropertyBuildItem(fullConfigName, returnType));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.it.config;

import java.math.BigDecimal;

import javax.validation.constraints.Size;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand All @@ -25,5 +27,6 @@ public static class GreetingConfiguration {
@Size(min = 2)
public String message;
public String suffix = "!";
public BigDecimal other;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ schedulerservice.cron.expr=0/10 * * * * ?

microprofile.custom.value = 456
configproperties.message=Hello
configproperties.other=1

quarkus.swagger-ui.always-include=true