Skip to content

Commit

Permalink
Merge pull request #30709 from radcortez/fix-30697
Browse files Browse the repository at this point in the history
Fix unknown build properties regression
  • Loading branch information
radcortez authored Jan 30, 2023
2 parents cdb856d + f81b774 commit 1345c2e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ ReadResult run() {
if (ni.hasNext() && PropertiesUtil.isPropertyInRoot(registeredRoots, ni)) {
// build time patterns
Container matched = buildTimePatternMap.match(ni);
boolean knownProperty = matched != null;
if (matched instanceof FieldContainer) {
ConfigValue configValue = config.getConfigValue(propertyName);
if (configValue.getValue() != null) {
Expand Down Expand Up @@ -471,6 +472,7 @@ ReadResult run() {
// build time (run time visible) patterns
ni.goToStart();
matched = buildTimeRunTimePatternMap.match(ni);
knownProperty = knownProperty || matched != null;
if (matched instanceof FieldContainer) {
ConfigValue configValue = config.getConfigValue(propertyName);
if (configValue.getValue() != null) {
Expand Down Expand Up @@ -501,6 +503,7 @@ ReadResult run() {
// run time patterns
ni.goToStart();
matched = runTimePatternMap.match(ni);
knownProperty = knownProperty || matched != null;
if (matched != null) {
// it's a run-time default (record for later)
ConfigValue configValue = withoutExpansion(() -> runtimeDefaultsConfig.getConfigValue(propertyName));
Expand All @@ -511,6 +514,7 @@ ReadResult run() {
// also check for the bootstrap properties since those need to be added to runTimeDefaultValues as well
ni.goToStart();
matched = bootstrapPatternMap.match(ni);
knownProperty = knownProperty || matched != null;
if (matched != null) {
// it's a run-time default (record for later)
ConfigValue configValue = withoutExpansion(() -> runtimeDefaultsConfig.getConfigValue(propertyName));
Expand All @@ -519,7 +523,7 @@ ReadResult run() {
}
}

if (matched == null) {
if (!knownProperty) {
unknownBuildProperties.add(propertyName);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.quarkus.extest;

import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toSet;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.LogRecord;

Expand All @@ -28,11 +30,22 @@ public class UnknownBuildConfigTest {
void unknownBuildConfig() {
List<LogRecord> logRecords = prodModeTestResults.getRetainedBuildLogRecords();

Optional<LogRecord> unknownBuildKey = logRecords.stream()
.filter(logRecord -> asList(Optional.ofNullable(logRecord.getParameters()).orElse(new Object[0]))
.contains("quarkus.build.unknown.prop"))
.findFirst();
assertTrue(unknownBuildKey.isPresent());
assertTrue(unknownBuildKey.get().getMessage().startsWith("Unrecognized configuration key"));
// These are the expected unknown properties in the test extension. This could probably be improved, because
// these are generated with the rename test. If there is a change we know that something happened.
Set<Object> unrecognized = logRecords.stream()
.filter(logRecord -> logRecord.getMessage().startsWith("Unrecognized configuration key"))
.map(logRecord -> Optional.ofNullable(logRecord.getParameters())
.map(parameters -> parameters[0])
.orElse(new Object[0]))
.collect(toSet());

assertEquals(7, logRecords.size());
assertTrue(unrecognized.contains("quarkus.unknown.prop"));
assertTrue(unrecognized.contains("quarkus.build.unknown.prop"));
assertTrue(unrecognized.contains("quarkus.rename-old.prop"));
assertTrue(unrecognized.contains("quarkus.rename-old.only-in-new"));
assertTrue(unrecognized.contains("quarkus.rename-old.only-in-old"));
assertTrue(unrecognized.contains("quarkus.rename-old.in-both"));
assertTrue(unrecognized.contains("quarkus.rename-old.with-default"));
}
}

0 comments on commit 1345c2e

Please sign in to comment.