[
https://issues.apache.org/jira/browse/ARTEMIS-4955?focusedWorklogId=928313&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-928313
]
ASF GitHub Bot logged work on ARTEMIS-4955:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 01/Aug/24 13:35
Start Date: 01/Aug/24 13:35
Worklog Time Spent: 10m
Work Description: 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.
Issue Time Tracking
-------------------
Worklog Id: (was: 928313)
Time Spent: 50m (was: 40m)
> Support broker properties from JSON files
> -----------------------------------------
>
> Key: ARTEMIS-4955
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4955
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Reporter: Domenico Francesco Bruscino
> Assignee: Domenico Francesco Bruscino
> Priority: Major
> Fix For: 2.37.0
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> The broker properties are low level, lower level than xml, however it is very
> powerful but the current format is too verbose and requires to escape
> characters that could be included in the broker properties: ' ', '
> ', '=', ':'. The JSON format is more compact and only requires to escape JSON
> reserved characters that are not typically used in the broker properties.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact