Skip to content

Commit

Permalink
Merge pull request #5321 from geoand/#5297
Browse files Browse the repository at this point in the history
Ensure that array config values are properly validated at startup
  • Loading branch information
geoand authored Nov 12, 2019
2 parents 383c21d + 5bcb558 commit 52ee9d0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void validateConfigProperties(ConfigRecorder recorder, List<ConfigPropertyBuildI
for (ConfigPropertyBuildItem item : configProperties) {
Type requiredType = item.getPropertyType();
String propertyType = requiredType.name().toString();
if (requiredType.kind() != Kind.ARRAY && requiredType.kind() != Kind.PRIMITIVE) {
if (requiredType.kind() != Kind.PRIMITIVE) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, propertyType));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ public class ServiceWithConfig {
@ConfigProperty(name = "web-message")
String message;

@ConfigProperty(name = "names")
String[] names;

public String host() {
return quarkusHost;
}

public String message() {
return message;
}

public String[] names() {
return names;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public String configMessage() {
return config.message();
}

@GET
@Path("/config/names")
@Produces("application/json")
public String configNames() {
return String.join(",", config.names());
}

@GET
@Path("/count")
public int count() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ quarkus.resteasy.gzip.enabled=true
quarkus.resteasy.gzip.max-input=10
quarkus.http.limits.max-body-size=1K
web-message=A message
names=quarkus,redhat
schedulerservice.cron.expr=0/10 * * * * ?

microprofile.custom.value = 456
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public void testConfigInjectionOfMessage() {
RestAssured.when().get("/test/config/message").then().body(is("A message"));
}

@Test
public void testConfigInjectionOfStringArray() {
RestAssured.when().get("/test/config/names").then().body(is("quarkus,redhat"));
}

@Test
public void testAnnotatedInterface() {
RestAssured.when().get("/interface").then().body(is("interface endpoint"));
Expand Down

0 comments on commit 52ee9d0

Please sign in to comment.