[
https://issues.apache.org/jira/browse/CRYPTO-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15352891#comment-15352891
]
Sebb edited comment on CRYPTO-90 at 6/28/16 12:12 PM:
------------------------------------------------------
An alternative approach would be to add a method to return a local Properties
instance.
For example (pseudocode):
{code}
private Properties getDefaultProperties() {
Properties props = new Properties(System.getProperties()); // default to
system
for (prop in ConfigurationKeys.SYSTEM_PROPERTIES_FILE) { // pseudo-code
if (System.getProperty(prop.name()) == null) { // add local prop if not
defined by system
props.addProperty(prop);
}
}
return props;
}
public getProperties() {
return new Properties(getDefaultProperties()); // protect the defaults
against change
}
{code}
This would allow arbitrary properties to be defined in the Properties instance
without needing to change any SystemProperties.
Note: the defaults processing could be done once by using the IODH idiom
was (Author: [email protected]):
An alternative approach would be to add a method to return a local Properties
instance.
For example (pseudocode):
{code}
private Properties getDefaultProperties() {
Properties props = new Properties(System.getProperties()); // default to
system
for (prop in ConfigurationKeys.SYSTEM_PROPERTIES_FILE) { // pseudo-code
if (System.getProperty(prop.name()) == null) { // add local prop if not
defined by system
props.addProperty(prop);
}
}
return props;
}
public getProperties() {
return new Properties(getDefaultProperties()); // protect the defaults
against change
}
{code}
This would allow arbitrary properties to be defined in the Properties instance
without needing to change any SystemProperties.
Note: the processing could be done once by using the IODH idiom, and new
instances
> Utils loads system properties during class loading
> --------------------------------------------------
>
> Key: CRYPTO-90
> URL: https://issues.apache.org/jira/browse/CRYPTO-90
> Project: Commons Crypto
> Issue Type: Bug
> Reporter: Sebb
>
> The Utils class reads properties from a properties file if it exists, and
> adds them to the set of System properties.
> There are several problems with this:
> - there's no way of knowing exactly when the properties will be processed,
> because it depends when the Utils class is first used
> - generally it's a bad idea to update System properties.
> - updates to System properties require additional privileges, so the
> behaviour of the code will depend on the environment in which it is run.
> - the code catches Throwable, which is not allowed.
> If there is a use case for supporting a properties file, it should be
> processed at a predictable stage in the code, should be done before
> command-line parameters are processed, and should not require updating System
> properties.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)