Skip to content

Commit

Permalink
check duplicate values (added log method) #1269
Browse files Browse the repository at this point in the history
Added a log method in ConfigLogging to handle duplicate values.
  • Loading branch information
fugerit79 authored and radcortez committed Dec 19, 2024
1 parent 1285338 commit d9c6de2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ private void load0(LineReader lr) throws IOException {
.withLineNumber(lr.lineNumber)
.build());
if (oldConfigValue != null) {
log.warnv("duplicate keys found for : {0}, source name : {1}", oldConfigValue.getName(),
oldConfigValue.getConfigSourceName());
ConfigLogging.log.duplicateValue(oldConfigValue.getName(), oldConfigValue.getConfigSourceName(),
oldConfigValue.getValue());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public interface ConfigLogging extends BasicLogger {
@LogMessage(level = Logger.Level.DEBUG)
@Message(id = 1006, value = "Loaded ConfigSource %s with ordinal %d")
void loadedConfigSource(String name, int ordinal);

@LogMessage(level = Logger.Level.WARN)
@Message(id = 1007, value = "Duplicate value found for name : %s, config source name : %s, (old value : %s)")
void duplicateValue(String key, String sourceName, String oldValue);

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void wrapValue() throws Exception {
}

@Test
void logDuplicateKeys() throws Exception {
void logDuplicateValue() throws Exception {
ConfigValueProperties map = new ConfigValueProperties("config", 1);
String config = "key=value\n" +
"key2=value\n" +
Expand Down

0 comments on commit d9c6de2

Please sign in to comment.