Skip to content

Commit d099b5f

Browse files
committed
Make the default config sources more robust when a security manager is installed
If we don't have permission to access system properties or the environment then fall back to defaults.
1 parent 2d31713 commit d099b5f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

internal-api/src/main/java/datadog/trace/bootstrap/config/provider/EnvironmentConfigSource.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ final class EnvironmentConfigSource extends ConfigProvider.Source {
88

99
@Override
1010
protected String get(String key) {
11-
return System.getenv(propertyNameToEnvironmentVariableName(key));
11+
try {
12+
return System.getenv(propertyNameToEnvironmentVariableName(key));
13+
} catch (SecurityException e) {
14+
return null;
15+
}
1216
}
1317

1418
@Override

internal-api/src/main/java/datadog/trace/bootstrap/config/provider/SystemPropertiesConfigSource.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ public final class SystemPropertiesConfigSource extends ConfigProvider.Source {
88

99
@Override
1010
protected String get(String key) {
11-
return System.getProperty(propertyNameToSystemPropertyName(key));
11+
try {
12+
return System.getProperty(propertyNameToSystemPropertyName(key));
13+
} catch (SecurityException e) {
14+
return null;
15+
}
1216
}
1317

1418
@Override

0 commit comments

Comments
 (0)