lavocatt commented on code in PR #5120:
URL: https://github.com/apache/activemq-artemis/pull/5120#discussion_r1700178993


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java:
##########
@@ -559,38 +562,41 @@ public Configuration parseProperties(String 
fileUrlToProperties) throws Exceptio
       fileUrlToProperties = resolvePropertiesSources(fileUrlToProperties);
       if (fileUrlToProperties != null) {
          for (String fileUrl : fileUrlToProperties.split(",")) {
-            Properties brokerProperties = new InsertionOrderedProperties();
             if (fileUrl.endsWith("/")) {
                // treat as a directory and parse every property file in 
alphabetical order
                File dir = new File(fileUrl);
                if (dir.exists()) {
-                  String[] files = dir.list((file, s) -> 
s.endsWith(".properties"));
+                  String[] files = dir.list((file, s) -> s.endsWith(".json") 
|| s.endsWith(".properties"));
                   if (files != null && files.length > 0) {
                      Arrays.sort(files);
                      for (String fileName : files) {
-                        try (FileInputStream fileInputStream = new 
FileInputStream(new File(dir, fileName));
-                             BufferedInputStream reader = new 
BufferedInputStream(fileInputStream)) {
-                           brokerProperties.clear();
-                           brokerProperties.load(reader);
-                           parsePrefixedProperties(this, fileName, 
brokerProperties, null);
-                        }
+                        parseFileProperties(new File(dir, fileName));
                      }
                   }
                }
             } else {
-               File file = new File(fileUrl);
-               try (FileInputStream fileInputStream = new 
FileInputStream(file);
-                    BufferedInputStream reader = new 
BufferedInputStream(fileInputStream)) {
-                  brokerProperties.load(reader);
-                  parsePrefixedProperties(this, file.getName(), 
brokerProperties, null);
-               }
+               parseFileProperties(new File(fileUrl));
             }
          }
       }
       parsePrefixedProperties(System.getProperties(), systemPropertyPrefix);
       return this;
    }
 
+   private void parseFileProperties(File file) throws Exception {
+      InsertionOrderedProperties brokerProperties = new 
InsertionOrderedProperties();
+      try (FileReader fileReader = new FileReader(file);
+           BufferedReader reader = new BufferedReader(fileReader)) {
+         if (file.getName().endsWith(".json")) {
+            brokerProperties.loadJson(reader);
+         } else {
+            brokerProperties.load(reader);
+         }
+      }
+
+      parsePrefixedProperties(this, file.getName(), brokerProperties, null);
+   }
+

Review Comment:
   @brusdev we don't have an openapi definition for the broker properties atm, 
but when we start to having one, we could easily add a validation step upon 
reading the file to ensure that any properties we're loading is valid according 
to the spec.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to