[jboss-jira] [JBoss JIRA] (JGRP-188) JGroups should not use System properties, because it's too restrictive
Julien Kronegg (Commented) (JIRA)
jira-events at lists.jboss.org
Wed Oct 19 07:49:45 EDT 2011
[ https://issues.jboss.org/browse/JGRP-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635740#comment-12635740 ]
Julien Kronegg commented on JGRP-188:
-------------------------------------
I would use a variant of Robert's suggestion (singleton that contains a Properties object), but simpler (I would argue that System Properties are global anyway, so using a singleton pattern would be a luxury).
This would require to update [{{org.jgroups.util.Util}}|https://github.com/belaban/JGroups/blob/master/src/org/jgroups/util/Util.java] as such:
- add the field {{private static Properties globalProperties=null;}}
- add a static setter for the {{globalProperties}} field
- modify the {{_getProperty(String,String)}} method (at line ~4099) in order to first check for the {{prop}} key in the {{globalProperties}}, then, if not found, in the System Properties, and finally use the default value if no value was found:
{code}
private static String _getProperty(String var, String default_value) {
if(var == null)
return null;
List<String list=parseCommaDelimitedStrings(var);
if (list==null ||list.isEmpty()) {
list=new ArrayList<String(1);
list.add(var);
}
for (String prop:list) {
retval = (globalProperties!=null?globalProperties.get(prop):null);
if (retval==null) {
// no value found from the global properties => look into the System Properties
try {
retval=System.getProperty(prop);
} catch (Throwable e) {
// failed to get the system property => do nothing
}
}
if (retval!=null) {
return retval;
}
}
return default_value;
}
{code}
Thus, when the {{globalProperties}} are not set, the System Properties will be used (unchanged behavior). Users who care about security would use the {{globalProperties}} and others will still use System Properties. The documentation may also be updated in order to warn the users about the (small) security risk of information disclosure.
Note that the {{getProperty(...)}} method at line ~3076 also uses {{System.getProperty(String)}}, but I did not check if a modification is required here.
> JGroups should not use System properties, because it's too restrictive
> ----------------------------------------------------------------------
>
> Key: JGRP-188
> URL: https://issues.jboss.org/browse/JGRP-188
> Project: JGroups
> Issue Type: Feature Request
> Affects Versions: 2.2.8, 2.2.9, 2.2.9.1
> Environment: all
> Reporter: Robert Stevenson
> Assignee: Bela Ban
> Priority: Minor
> Fix For: 2.4
>
> Original Estimate: 1 day
> Remaining Estimate: 1 day
>
> JGroups should not use System properties for configuration, it should instead use a Global Configurator class (singleton), similar to log4j; which just contains a Properties object. This would allow JGroups to be much easier to move around to different environments. For example : (Applet), which does not have access to easily change System properties, on a per applet basis.
> This new class could have a mapping/conversion method to make the current -D command line options be put into this new Properties Configurator for backward compatibility
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list