markobean commented on code in PR #6061:
URL: https://github.com/apache/nifi/pull/6061#discussion_r896951762


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java:
##########
@@ -211,6 +213,25 @@ public NiFiProperties get() {
         return instance;
     }
 
+    private void checkForDuplicates(File file) {
+        if (file == null || !file.exists() || !file.canRead()) {
+            throw new IllegalArgumentException("NiFi properties file missing 
or unreadable");
+        }
+
+        Props properties = new Props();
+        try (final InputStream inputStream = new BufferedInputStream(new 
FileInputStream(file))) {
+            properties.load(inputStream);
+        } catch (final Exception e) {
+            throw new RuntimeException(String.format("Loading Application 
Properties [%s] failed", file), e);
+        }
+
+        Set<String> duplicateKeys = properties.duplicateKeySet();
+        if (!duplicateKeys.isEmpty()) {
+            duplicateKeys.forEach(v -> logger.error("Multiple entries with 
different values found for key '{}'.", v));
+            throw new IllegalArgumentException("Duplicate keys were detected 
in the properties file. See previous errors.");

Review Comment:
   Log messages have been aggregated.



-- 
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

Reply via email to