You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/11/19 00:58:43 UTC
[GitHub] [druid] paul-rogers opened a new issue #11952: System properties should override file properties, not visa-versa
paul-rogers opened a new issue #11952:
URL: https://github.com/apache/druid/issues/11952
### Affected Version
Latest `master` as of issue date.
### Description
A typical configuration rule is that system properties override file-based configuration properties. Quick example. Assume I have `runtime.properties` with:
```text
foo=bar
```
For a specific run (for testing, specific need, etc.) I specify `-Dfoo=mumble` on the JVM command line. In most systems, the system property will override the file property. But, according to the code, in Druid the opposite happens. That is, the `-D` option is ignored. Further, one can override any system property from the properties file, even those which should not be changed (such as CPUs, user name, home directory, etc.)
The problem occurs in `PropertiesModule`:
```java
public void configure(Binder binder)
{
final Properties fileProps = new Properties();
Properties systemProps = System.getProperties();
Properties props = new Properties(fileProps);
props.putAll(systemProps);
for (String propertiesFile : propertiesFiles) {
...
fileProps.load(in);
...
}
```
The implementation of `load()` simply overwrites any existing property value. We use this to allow `runtime.properties` to override `common.runtime.properties`.
### Suggested change
Simply move the `props.putAll(systemProps);` to come after all file properties are loaded.
The change is trivial. The question, however, is if this design is intentional, and if so, why? Do we have use cases that depend on the ability to replace (for Druid's use) system-defined properties?
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org