Skip to content

Commit

Permalink
getting indiv props instead of reading all props (#444)
Browse files Browse the repository at this point in the history
Secured applications may not have access to all system properties on
a server. Making this change to prevent reading all the system properties
and just read the properties that are required for creating the
DefaultMonitorRegistry instance.

Fixes #443.
  • Loading branch information
ravikancherla authored and brharrington committed Mar 28, 2018
1 parent 172ab31 commit 710a42e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Expand Up @@ -89,7 +89,7 @@ public String tagString() {

static String getAutoScaleGroup() {
try {
String credFileProperty = System.getProperties().getProperty(
String credFileProperty = System.getProperty(
AwsPropertyKeys.AWS_CREDENTIALS_FILE.getBundle());
AWSCredentials credentials;

Expand Down
Expand Up @@ -61,7 +61,7 @@ public static MonitorRegistry getInstance() {
* Creates a new instance based on system properties.
*/
DefaultMonitorRegistry() {
this(System.getProperties());
this(loadProps());
}

/**
Expand Down Expand Up @@ -118,6 +118,24 @@ private static ObjectNameMapper getObjectNameMapper(Properties props) {

return mapper;
}

private static Properties loadProps() {
String registryClassProp = System.getProperty(REGISTRY_CLASS_PROP);
String registryNameProp = System.getProperty(REGISTRY_NAME_PROP);
String registryJmxNameProp = System.getProperty(REGISTRY_JMX_NAME_PROP);

Properties props = new Properties();
if (registryClassProp != null) {
props.setProperty(REGISTRY_CLASS_PROP, registryClassProp);
}
if (registryNameProp != null) {
props.setProperty(REGISTRY_NAME_PROP, registryNameProp);
}
if (registryJmxNameProp != null) {
props.setProperty(REGISTRY_JMX_NAME_PROP, registryJmxNameProp);
}
return props;
}

/**
* The set of registered Monitor objects.
Expand Down

0 comments on commit 710a42e

Please sign in to comment.