Skip to content

Commit

Permalink
Merge pull request #13524 from geoand/#13523
Browse files Browse the repository at this point in the history
Ensure that primitive types in @ConfigProperties work as expected
  • Loading branch information
geoand authored Nov 27, 2020
2 parents 1a43dbe + 12e8fcc commit 088570f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,10 @@ private static void populateTypicalProperty(MethodCreator methodCreator, ResultH
createWriteValue(methodCreator, configObject, field, setter, useFieldAccess, setterValue);

}
configPropertyBuildItemCandidates
.add(new ConfigPropertyBuildItemCandidate(field.name(), fullConfigName, fieldType));
if (field.type().kind() != Type.Kind.PRIMITIVE) { // the JVM assigns primitive types a default even though it doesn't show up in the bytecode
configPropertyBuildItemCandidates
.add(new ConfigPropertyBuildItemCandidate(field.name(), fullConfigName, fieldType));
}
}

private static String getFullConfigName(String prefixStr, ConfigProperties.NamingStrategy namingStrategy, FieldInfo field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void testConfiguredValues() {
assertEquals(Arrays.asList(1, 2, 3, 4), dummyBean.getNumbers());
assertEquals("default", dummyBean.getUnset());
assertTrue(dummyBean.isBoolWithDefault());
assertFalse(dummyBean.isUnsetBoolean());
assertTrue(dummyBean.getOptionalInt().isPresent());
assertEquals(100, dummyBean.getOptionalInt().get());
assertFalse(dummyBean.getOptionalString().isPresent());
Expand Down Expand Up @@ -69,6 +70,10 @@ boolean isBoolWithDefault() {
return dummyProperties.boolWithDefault;
}

boolean isUnsetBoolean() {
return dummyProperties.unsetBoolean;
}

Optional<Integer> getOptionalInt() {
return dummyProperties.optionalInt;
}
Expand All @@ -92,6 +97,7 @@ public static class DummyProperties {
public String name;
public String unset = "default";
public boolean boolWithDefault = false;
public boolean unsetBoolean;
public List<Integer> numbers;
public Optional<Integer> optionalInt;
public Optional<String> optionalString;
Expand Down

0 comments on commit 088570f

Please sign in to comment.