michael81877 commented on code in PR #6061: URL: https://github.com/apache/nifi/pull/6061#discussion_r877815352
########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java: ########## @@ -211,6 +220,45 @@ public NiFiProperties get() { return instance; } + private void checkForDuplicates(File file) { + Map<String, String> properties = new HashMap<>(); + Map<String, Set<String>> duplicateProperties = new HashMap<>(); + Pattern keyPattern = Pattern.compile("([^!#=][^=]*)=(.*)"); + + if (file == null) { + throw new IllegalArgumentException("NiFi properties file missing or unreadable"); + } + // Scan the properties file for duplicate keys + try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { + String line; + while ((line = bufferedReader.readLine()) != null) { + Matcher matcher = keyPattern.matcher(line); + + if (matcher.matches()) { + String key = matcher.group(1); + String value = matcher.group(2); + + String existingValue = properties.put(key, value); + + if (existingValue != null && !existingValue.equals(value)) { Review Comment: Did you want to log a warning when there are duplicates but the values are the same? I believe this was noted as an exceptional case and the startup should continue. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org