You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/06/14 15:09:36 UTC

[GitHub] [nifi] markobean commented on a diff in pull request #6061: NIFI-5378 prevent duplicate keys with different values in nifi.p…

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


##########
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()) {

Review Comment:
   Updated the location of the check to avoid duplicate loading/parsing of properties file.



-- 
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-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org