[
https://issues.apache.org/jira/browse/KARAF-5440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16214992#comment-16214992
]
ASF GitHub Bot commented on KARAF-5440:
---------------------------------------
jbonofre closed pull request #386: [KARAF-5440] Allow for overrides to values
in system.properties.
URL: https://github.com/apache/karaf/pull/386
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/assemblies/features/base/src/main/resources/resources/etc/system.properties
b/assemblies/features/base/src/main/resources/resources/etc/system.properties
index be76d42678..77c316d3aa 100644
---
a/assemblies/features/base/src/main/resources/resources/etc/system.properties
+++
b/assemblies/features/base/src/main/resources/resources/etc/system.properties
@@ -22,6 +22,9 @@
# properties at the very beginning of the Karaf's boot process.
#
+# Properties file inclusions (as a space separated list of relative paths)
+# Included files will override the values specified in this file
+${optionals} = custom.system.properties
# Log level when the pax-logging service is not available
# This level will only be used while the pax-logging service bundle
diff --git
a/assemblies/features/static/src/main/resources/resources/etc/system.properties
b/assemblies/features/static/src/main/resources/resources/etc/system.properties
index c5f8b4b407..a696c0fbf2 100644
---
a/assemblies/features/static/src/main/resources/resources/etc/system.properties
+++
b/assemblies/features/static/src/main/resources/resources/etc/system.properties
@@ -22,6 +22,9 @@
# properties at the very beginning of the Karaf's boot process.
#
+# Properties file inclusions (as a space separated list of relative paths)
+# Included files will override the values specified in this file
+${optionals} = custom.system.properties
# Log level when the pax-logging service is not available
# This level will only be used while the pax-logging service bundle
diff --git
a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/system.properties
b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/system.properties
index 0835bbbb1c..43014007be 100644
---
a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/system.properties
+++
b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/system.properties
@@ -22,6 +22,9 @@
# properties at the very beginning of the Karaf's boot process.
#
+# Properties file inclusions (as a space separated list of relative paths)
+# Included files will override the values specified in this file
+${optionals} = custom.system.properties
# Log level when the pax-logging service is not available
# This level will only be used while the pax-logging service bundle
diff --git
a/util/src/main/java/org/apache/karaf/util/config/PropertiesLoader.java
b/util/src/main/java/org/apache/karaf/util/config/PropertiesLoader.java
index 31f30fa703..414f6a937f 100644
--- a/util/src/main/java/org/apache/karaf/util/config/PropertiesLoader.java
+++ b/util/src/main/java/org/apache/karaf/util/config/PropertiesLoader.java
@@ -99,13 +99,16 @@ public static Properties loadConfigProperties(File file)
throws Exception {
* @throws IOException if the system file can't be loaded.
*/
public static void loadSystemProperties(File file) throws IOException {
- Properties props = new Properties(false);
+ Properties props = null;
try {
- props.load(file);
- } catch (Exception e1) {
- // Ignore
+ URL configPropURL = file.toURI().toURL();
+ props = loadPropertiesFile(configPropURL, true);
}
-
+ catch (Exception ex) {
+ // Ignore
+ return;
+ }
+
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
String name = (String) e.nextElement();
if (name.startsWith(OVERRIDE_PREFIX)) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> No override facility for properties in system.properties
> --------------------------------------------------------
>
> Key: KARAF-5440
> URL: https://issues.apache.org/jira/browse/KARAF-5440
> Project: Karaf
> Issue Type: Bug
> Components: karaf-core
> Reporter: Tom Quarendon
> Assignee: Jean-Baptiste Onofré
> Priority: Minor
> Fix For: 4.2.0, 4.1.3
>
>
> There are two properties files in karaf that give global properties of
> various kinds, system.properties and config.properties.
> The "config.properties" file has a facility to override properties within it
> by putting values in the "custom.properties" file. We use this to tweak
> certain values in out custom distribution.
> There's no such facility though for the "system.properties" file.
> At the moment we therefore hold a copy of the whole system.properties file
> with a couple of modifications and include that in our distribution. This is
> fragile though. For example, recently one of the properties was changes by a
> commit to karaf and it took me a while to work out why things suddenly
> started behaving differently (this isn't a criticism, I'm just pointing out
> the fragility, in case it wasn't clear).
> It looks like there wouldn't be any particular reason why this couldn't be
> done by org.apache.karaf.util.config.PropertiesLoader. I'm happy to provide a
> pull request for consideration. I would have suggested having an ${optionals}
> line in the system.properties file that would load a file called, say,
> custom.system.properties. I would have just replaced the code to load the
> properties in loadSystemProperties with a call to loadPropertiesFile.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)