diff --git a/components/environment/src/main/java/datadog/environment/EnvironmentVariables.java b/components/environment/src/main/java/datadog/environment/EnvironmentVariables.java index 2be22a7ad10..b99900e0d85 100644 --- a/components/environment/src/main/java/datadog/environment/EnvironmentVariables.java +++ b/components/environment/src/main/java/datadog/environment/EnvironmentVariables.java @@ -1,6 +1,5 @@ package datadog.environment; -import javax.annotation.Nonnull; import javax.annotation.Nullable; /** @@ -32,7 +31,7 @@ private EnvironmentVariables() {} * @return The environment variable value, {@code defaultValue} if missing, can't be retrieved or * the environment variable name is {@code null}. */ - public static String getOrDefault(@Nonnull String name, String defaultValue) { + public static String getOrDefault(String name, String defaultValue) { if (name == null) { return defaultValue; } diff --git a/components/environment/src/main/java/datadog/environment/SystemProperties.java b/components/environment/src/main/java/datadog/environment/SystemProperties.java index 2a64d30d154..a4fd4753df6 100644 --- a/components/environment/src/main/java/datadog/environment/SystemProperties.java +++ b/components/environment/src/main/java/datadog/environment/SystemProperties.java @@ -1,6 +1,6 @@ package datadog.environment; -import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Safely queries system properties against security manager. @@ -18,7 +18,7 @@ private SystemProperties() {} * @return The system property value, {@code null} if missing, can't be retrieved, or the system * property name is {@code null}. */ - public static String get(String property) { + public static @Nullable String get(String property) { return getOrDefault(property, null); } @@ -31,7 +31,7 @@ public static String get(String property) { * @return The system property value, {@code defaultValue} if missing, can't be retrieved, or the * system property name is {@code null}. */ - public static String getOrDefault(@Nonnull String property, String defaultValue) { + public static String getOrDefault(String property, String defaultValue) { if (property == null) { return defaultValue; } @@ -50,6 +50,9 @@ public static String getOrDefault(@Nonnull String property, String defaultValue) * @return {@code true} if the system property was successfully set, {@code} false otherwise. */ public static boolean set(String property, String value) { + if (property == null || value == null) { + return false; + } try { System.setProperty(property, value); return true; @@ -57,4 +60,22 @@ public static boolean set(String property, String value) { return false; } } + + /** + * Clears a system property. + * + * @param property The system property name to clear. + * @return The previous value of the system property, {@code null} if there was no prior property + * and property can't be cleared. + */ + public static @Nullable String clear(String property) { + if (property == null) { + return null; + } + try { + return System.clearProperty(property); + } catch (SecurityException ignored) { + return null; + } + } } diff --git a/components/environment/src/main/java/datadog/environment/package-info.java b/components/environment/src/main/java/datadog/environment/package-info.java new file mode 100644 index 00000000000..ad2be37a1cd --- /dev/null +++ b/components/environment/src/main/java/datadog/environment/package-info.java @@ -0,0 +1,4 @@ +@ParametersAreNonnullByDefault +package datadog.environment; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/components/environment/src/test/java/datadog/environment/SystemPropertiesTest.java b/components/environment/src/test/java/datadog/environment/SystemPropertiesTest.java index 713da94fafe..f376cce7728 100644 --- a/components/environment/src/test/java/datadog/environment/SystemPropertiesTest.java +++ b/components/environment/src/test/java/datadog/environment/SystemPropertiesTest.java @@ -38,11 +38,29 @@ void testGetOrDefault() { @Test void testSet() { - String testProperty = "test.property"; - String testValue = "test-value"; - assumeTrue(SystemProperties.get(testProperty) == null); - + String testProperty = "test.set.property"; + String testValue = "test.set.value"; + assertNull(SystemProperties.get(testProperty)); assertTrue(SystemProperties.set(testProperty, testValue)); assertEquals(testValue, SystemProperties.get(testProperty)); + // Null values + assertDoesNotThrow(() -> SystemProperties.set(testProperty, null)); + assertFalse(SystemProperties.set(testProperty, null)); + assertDoesNotThrow(() -> SystemProperties.set(null, testValue)); + assertFalse(SystemProperties.set(null, testValue)); + } + + @Test + void testClear() { + String testProperty = "test.clear.property"; + String testValue = "test.clear.value"; + assertNull(SystemProperties.get(testProperty)); + assertNull(SystemProperties.clear(testProperty)); + assumeTrue(SystemProperties.set(testProperty, testValue)); + assertEquals(testValue, SystemProperties.clear(testProperty)); + assertNull(SystemProperties.clear(testProperty)); + // Null values + assertDoesNotThrow(() -> SystemProperties.clear(null)); + assertNull(SystemProperties.clear(null)); } } diff --git a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/benchmark/StaticEventLogger.java b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/benchmark/StaticEventLogger.java index 3e583f4b3e3..d8e05b5e1cc 100644 --- a/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/benchmark/StaticEventLogger.java +++ b/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/benchmark/StaticEventLogger.java @@ -1,5 +1,6 @@ package datadog.trace.bootstrap.benchmark; +import datadog.environment.SystemProperties; import java.io.*; import java.nio.charset.StandardCharsets; import java.util.Objects; @@ -18,8 +19,8 @@ public class StaticEventLogger { static { BufferedWriter writer = null; - if ("true".equalsIgnoreCase(System.getProperty("dd.benchmark.enabled"))) { - String dir = System.getProperty("dd.benchmark.output.dir"); + if ("true".equalsIgnoreCase(SystemProperties.get("dd.benchmark.enabled"))) { + String dir = SystemProperties.get("dd.benchmark.output.dir"); dir = (dir != null ? dir + File.separator : ""); String fileName = dir + "startup_" + System.currentTimeMillis() + ".csv"; diff --git a/dd-java-agent/agent-builder/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java b/dd-java-agent/agent-builder/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java index e56fda40497..d3e0926cf92 100644 --- a/dd-java-agent/agent-builder/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java +++ b/dd-java-agent/agent-builder/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java @@ -5,6 +5,7 @@ import static datadog.trace.agent.tooling.bytebuddy.matcher.GlobalIgnoresMatcher.globalIgnoresMatcher; import static net.bytebuddy.matcher.ElementMatchers.isDefaultFinalizer; +import datadog.environment.SystemProperties; import datadog.trace.agent.tooling.bytebuddy.SharedTypePools; import datadog.trace.agent.tooling.bytebuddy.iast.TaintableRedefinitionStrategyListener; import datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers; @@ -318,18 +319,17 @@ public static Set getEnabledSystems() { } private static void addByteBuddyRawSetting() { - final String savedPropertyValue = System.getProperty(TypeDefinition.RAW_TYPES_PROPERTY); - try { - System.setProperty(TypeDefinition.RAW_TYPES_PROPERTY, "true"); - final boolean rawTypes = TypeDescription.AbstractBase.RAW_TYPES; - if (!rawTypes && DEBUG) { - log.debug("Too late to enable {}", TypeDefinition.RAW_TYPES_PROPERTY); - } - } finally { + final String savedPropertyValue = SystemProperties.get(TypeDefinition.RAW_TYPES_PROPERTY); + final boolean overridden = SystemProperties.set(TypeDefinition.RAW_TYPES_PROPERTY, "true"); + final boolean rawTypes = TypeDescription.AbstractBase.RAW_TYPES; + if (!rawTypes && DEBUG) { + log.debug("Too late to enable {}", TypeDefinition.RAW_TYPES_PROPERTY); + } + if (overridden) { if (savedPropertyValue == null) { - System.clearProperty(TypeDefinition.RAW_TYPES_PROPERTY); + SystemProperties.clear(TypeDefinition.RAW_TYPES_PROPERTY); } else { - System.setProperty(TypeDefinition.RAW_TYPES_PROPERTY, savedPropertyValue); + SystemProperties.set(TypeDefinition.RAW_TYPES_PROPERTY, savedPropertyValue); } } } diff --git a/dd-java-agent/src/test/groovy/datadog/trace/agent/InitializationTelemetryTest.groovy b/dd-java-agent/src/test/groovy/datadog/trace/agent/InitializationTelemetryTest.groovy index 09df6a97e44..6c957a4a3fd 100644 --- a/dd-java-agent/src/test/groovy/datadog/trace/agent/InitializationTelemetryTest.groovy +++ b/dd-java-agent/src/test/groovy/datadog/trace/agent/InitializationTelemetryTest.groovy @@ -58,15 +58,15 @@ class InitializationTelemetryTest extends Specification { }) def "incomplete agent start-up"() { // In this case, the SecurityManager blocks a custom permission that is checked by bytebuddy causing - // agent initialization to fail. However, we should catch the exception allowing the application + // agent initialization to fail. However, we should catch the exception allowing the application // to run normally. when: def result = InitializationTelemetryCheck.runTestJvm(InitializationTelemetryCheck.BlockByteBuddy) - then: + then: 'should complete successfully and catch error' result.exitCode == 0 !result.telemetryJson.contains('library_entrypoint.complete') - result.telemetryJson.contains('error_type:java.lang.IllegalStateException') + result.telemetryJson.contains('error_type:') } @IgnoreIf(reason = "SecurityManager is permanently disabled as of JDK 24", value = { diff --git a/internal-api/src/main/java/datadog/trace/api/Config.java b/internal-api/src/main/java/datadog/trace/api/Config.java index 518520b6ead..0a1727a1b37 100644 --- a/internal-api/src/main/java/datadog/trace/api/Config.java +++ b/internal-api/src/main/java/datadog/trace/api/Config.java @@ -632,8 +632,10 @@ import static datadog.trace.util.CollectionUtils.tryMakeImmutableSet; import static datadog.trace.util.Strings.propertyNameToEnvironmentVariableName; +import datadog.environment.EnvironmentVariables; import datadog.environment.JavaVirtualMachine; import datadog.environment.OperatingSystem; +import datadog.environment.SystemProperties; import datadog.trace.api.civisibility.CiVisibilityWellKnownTags; import datadog.trace.api.config.GeneralConfig; import datadog.trace.api.config.ProfilingConfig; @@ -1239,7 +1241,7 @@ private Config(final ConfigProvider configProvider, final InstrumenterConfig ins configFileStatus = configProvider.getConfigFileStatus(); runtimeIdEnabled = configProvider.getBoolean(RUNTIME_ID_ENABLED, true, RUNTIME_METRICS_RUNTIME_ID_ENABLED); - runtimeVersion = System.getProperty("java.version", "unknown"); + runtimeVersion = SystemProperties.getOrDefault("java.version", "unknown"); // Note: We do not want APiKey to be loaded from property for security reasons // Note: we do not use defined default here @@ -3409,7 +3411,7 @@ public static boolean isDatadogProfilerSafeInCurrentEnvironment() { // don't want to put this logic (which will evolve) in the public ProfilingConfig, and can't // access Platform there if (!JavaVirtualMachine.isJ9() && isJavaVersion(8)) { - String arch = System.getProperty("os.arch"); + String arch = SystemProperties.get("os.arch"); if ("aarch64".equalsIgnoreCase(arch) || "arm64".equalsIgnoreCase(arch)) { return false; } @@ -4453,12 +4455,12 @@ public CiVisibilityWellKnownTags getCiVisibilityWellKnownTags() { getRuntimeId(), getEnv(), LANGUAGE_TAG_VALUE, - System.getProperty("java.runtime.name"), - System.getProperty("java.version"), - System.getProperty("java.vendor"), - System.getProperty("os.arch"), - System.getProperty("os.name"), - System.getProperty("os.version"), + SystemProperties.get("java.runtime.name"), + SystemProperties.get("java.version"), + SystemProperties.get("java.vendor"), + SystemProperties.get("os.arch"), + SystemProperties.get("os.name"), + SystemProperties.get("os.version"), isServiceNameSetByUser() ? "true" : "false"); } @@ -5197,7 +5199,7 @@ private static boolean isWindowsOS() { } private static String getEnv(String name) { - String value = System.getenv(name); + String value = EnvironmentVariables.get(name); if (value != null) { ConfigCollector.get().put(name, value, ConfigOrigin.ENV); } @@ -5220,7 +5222,7 @@ private static String getProp(String name) { } private static String getProp(String name, String def) { - String value = System.getProperty(name, def); + String value = SystemProperties.getOrDefault(name, def); if (value != null) { ConfigCollector.get().put(name, value, ConfigOrigin.JVM_PROP); } diff --git a/internal-api/src/main/java/datadog/trace/api/Platform.java b/internal-api/src/main/java/datadog/trace/api/Platform.java index 36dd9921ac5..f8293f654ba 100644 --- a/internal-api/src/main/java/datadog/trace/api/Platform.java +++ b/internal-api/src/main/java/datadog/trace/api/Platform.java @@ -5,6 +5,8 @@ import static datadog.environment.JavaVirtualMachine.isJavaVersionAtLeast; import static datadog.environment.JavaVirtualMachine.isOracleJDK8; +import datadog.environment.SystemProperties; + /** * This class is used early on during premain; it must not touch features like JMX or JUL in case * they trigger early loading/binding. @@ -51,7 +53,7 @@ private static boolean checkForJfr() { private static boolean checkForNativeImageBuilder() { try { - return "org.graalvm.nativeimage.builder".equals(System.getProperty("jdk.module.main")); + return "org.graalvm.nativeimage.builder".equals(SystemProperties.get("jdk.module.main")); } catch (Throwable e) { return false; } diff --git a/internal-api/src/main/java/datadog/trace/api/env/CapturedEnvironment.java b/internal-api/src/main/java/datadog/trace/api/env/CapturedEnvironment.java index 47b2daacc9e..956db28c2de 100644 --- a/internal-api/src/main/java/datadog/trace/api/env/CapturedEnvironment.java +++ b/internal-api/src/main/java/datadog/trace/api/env/CapturedEnvironment.java @@ -1,5 +1,6 @@ package datadog.trace.api.env; +import datadog.environment.EnvironmentVariables; import datadog.environment.JavaVirtualMachine; import datadog.trace.api.config.GeneralConfig; import java.io.File; @@ -77,8 +78,8 @@ static void useFixedProcessInfo(final ProcessInfo processInfo) { * autodetection will return either the JAR filename or the java main class. */ private String autodetectServiceName() { - String inAas = System.getenv("DD_AZURE_APP_SERVICES"); - String siteName = System.getenv("WEBSITE_SITE_NAME"); + String inAas = EnvironmentVariables.get("DD_AZURE_APP_SERVICES"); + String siteName = EnvironmentVariables.get("WEBSITE_SITE_NAME"); if (("true".equalsIgnoreCase(inAas) || "1".equals(inAas)) && siteName != null) { return siteName; diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/AgentArgsInjector.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/AgentArgsInjector.java index 967f5a7dda4..3254c30db7d 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/AgentArgsInjector.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/AgentArgsInjector.java @@ -1,5 +1,7 @@ package datadog.trace.bootstrap.config.provider; +import datadog.environment.EnvironmentVariables; +import datadog.environment.SystemProperties; import datadog.trace.util.Strings; import java.util.Map; @@ -21,14 +23,14 @@ public static void injectAgentArgsConfig(Map args) { } for (Map.Entry e : args.entrySet()) { String propertyName = e.getKey(); - String existingPropertyValue = System.getProperty(propertyName); + String existingPropertyValue = SystemProperties.get(propertyName); if (existingPropertyValue != null) { // system properties should have higher priority than agent arguments continue; } String envVarName = Strings.toEnvVar(propertyName); - String envVarValue = System.getenv(envVarName); + String envVarValue = EnvironmentVariables.get(envVarName); if (envVarValue != null) { // env variables should have higher priority than agent arguments continue; diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java index 0a2715dd11a..1edeb072c80 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java @@ -2,6 +2,7 @@ import static datadog.trace.api.config.GeneralConfig.CONFIGURATION_FILE; +import datadog.environment.SystemProperties; import datadog.trace.api.ConfigCollector; import datadog.trace.api.ConfigOrigin; import de.thetaphi.forbiddenapis.SuppressForbidden; @@ -471,8 +472,11 @@ private static Properties loadConfigurationFile(ConfigProvider configProvider) { } // Normalizing tilde (~) paths for unix systems - configurationFilePath = - configurationFilePath.replaceFirst("^~", System.getProperty("user.home")); + String home; + if (configurationFilePath.charAt(0) == '~' + && (home = SystemProperties.get("user.home")) != null) { + configurationFilePath = home + configurationFilePath.substring(1); + } // Configuration properties file is optional final File configurationFile = new File(configurationFilePath); diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/EnvironmentConfigSource.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/EnvironmentConfigSource.java index ffbdf6f77f2..c8531f6a094 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/EnvironmentConfigSource.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/EnvironmentConfigSource.java @@ -1,22 +1,19 @@ package datadog.trace.bootstrap.config.provider; +import static datadog.trace.api.ConfigOrigin.ENV; import static datadog.trace.util.Strings.propertyNameToEnvironmentVariableName; +import datadog.environment.EnvironmentVariables; import datadog.trace.api.ConfigOrigin; final class EnvironmentConfigSource extends ConfigProvider.Source { - @Override protected String get(String key) { - try { - return System.getenv(propertyNameToEnvironmentVariableName(key)); - } catch (SecurityException e) { - return null; - } + return EnvironmentVariables.get(propertyNameToEnvironmentVariableName(key)); } @Override public ConfigOrigin origin() { - return ConfigOrigin.ENV; + return ENV; } } diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/OtelEnvironmentConfigSource.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/OtelEnvironmentConfigSource.java index 11ab4841a29..863a59fdcf8 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/OtelEnvironmentConfigSource.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/OtelEnvironmentConfigSource.java @@ -14,7 +14,10 @@ import static datadog.trace.api.config.TracerConfig.RESPONSE_HEADER_TAGS; import static datadog.trace.api.config.TracerConfig.TRACE_PROPAGATION_STYLE; import static datadog.trace.api.config.TracerConfig.TRACE_SAMPLE_RATE; +import static datadog.trace.util.Strings.toEnvVar; +import datadog.environment.EnvironmentVariables; +import datadog.environment.SystemProperties; import datadog.trace.api.ConfigOrigin; import datadog.trace.api.TracePropagationStyle; import datadog.trace.api.telemetry.OtelEnvMetricCollector; @@ -141,12 +144,8 @@ private String getOtelProperty(String otelSysProp, String ddSysProp) { } String ddValue = getDatadogProperty(ddSysProp); if (null != ddValue) { - String otelEnvVar = Strings.toEnvVar(otelSysProp); - log.warn( - "Both {} and {} are set, ignoring {}", - Strings.toEnvVar(ddSysProp), - otelEnvVar, - otelEnvVar); + String otelEnvVar = toEnvVar(otelSysProp); + log.warn("Both {} and {} are set, ignoring {}", toEnvVar(ddSysProp), otelEnvVar, otelEnvVar); otelEnvMetricCollector.setHidingOtelEnvVarMetric( Strings.toEnvVarLowerCase(otelSysProp), Strings.toEnvVarLowerCase(ddSysProp)); return null; @@ -186,9 +185,9 @@ private String getDatadogProperty(String sysProp) { *

Checks system properties and environment variables. */ private static String getProperty(String sysProp) { - String value = System.getProperty(sysProp); + String value = SystemProperties.get(sysProp); if (null == value) { - value = System.getenv(Strings.toEnvVar(sysProp)); + value = EnvironmentVariables.get(toEnvVar(sysProp)); } return value; } @@ -204,8 +203,10 @@ private void capture(String key, String value) { private static Properties loadOtelConfigFile() { String path = getProperty("otel.javaagent.configuration-file"); if (null != path && !path.isEmpty()) { - if (path.charAt(0) == '~') { - path = System.getProperty("user.home") + path.substring(1); + // Inflate '~' prefix as home folder + String home; + if (path.charAt(0) == '~' && (home = SystemProperties.get("user.home")) != null) { + path = home + path.substring(1); } File file = new File(path); if (file.exists()) { diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigParser.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigParser.java index 90a17667c56..bec1dbe5c38 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigParser.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/StableConfigParser.java @@ -1,5 +1,7 @@ package datadog.trace.bootstrap.config.provider; +import datadog.environment.EnvironmentVariables; +import datadog.environment.SystemProperties; import datadog.trace.bootstrap.config.provider.stableconfig.Rule; import datadog.trace.bootstrap.config.provider.stableconfig.Selector; import datadog.trace.bootstrap.config.provider.stableconfig.StableConfig; @@ -153,7 +155,7 @@ static boolean selectorMatch(String origin, List matches, String operato if (key == null) { return false; } - String envValue = System.getenv(key.toUpperCase(Locale.ROOT)); + String envValue = EnvironmentVariables.get(key.toUpperCase(Locale.ROOT)); return matchOperator(envValue, operator, matches); case "process_arguments": if (key == null) { @@ -166,7 +168,7 @@ static boolean selectorMatch(String origin, List matches, String operato key); return false; } - String argValue = System.getProperty(key.substring(2)); + String argValue = SystemProperties.get(key.substring(2)); return matchOperator(argValue, operator, matches); case "tags": // TODO: Support this down the line (Must define the source of "tags" first) @@ -229,7 +231,7 @@ private static String processTemplateVar(String templateVar) throws IOException if (envVar.isEmpty()) { throw new IOException("Empty environment variable name in template"); } - String value = System.getenv(envVar.toUpperCase(Locale.ROOT)); + String value = EnvironmentVariables.get(envVar.toUpperCase(Locale.ROOT)); if (value == null || value.isEmpty()) { return UNDEFINED_VALUE; } @@ -246,7 +248,7 @@ private static String processTemplateVar(String templateVar) throws IOException processArg); return UNDEFINED_VALUE; } - String value = System.getProperty(processArg.substring(2)); + String value = SystemProperties.get(processArg.substring(2)); if (value == null || value.isEmpty()) { return UNDEFINED_VALUE; } diff --git a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/SystemPropertiesConfigSource.java b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/SystemPropertiesConfigSource.java index a0d561b5a37..0ad6e15fa6d 100644 --- a/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/SystemPropertiesConfigSource.java +++ b/internal-api/src/main/java/datadog/trace/bootstrap/config/provider/SystemPropertiesConfigSource.java @@ -1,22 +1,19 @@ package datadog.trace.bootstrap.config.provider; +import static datadog.trace.api.ConfigOrigin.JVM_PROP; import static datadog.trace.util.Strings.propertyNameToSystemPropertyName; +import datadog.environment.SystemProperties; import datadog.trace.api.ConfigOrigin; public final class SystemPropertiesConfigSource extends ConfigProvider.Source { - @Override protected String get(String key) { - try { - return System.getProperty(propertyNameToSystemPropertyName(key)); - } catch (SecurityException e) { - return null; - } + return SystemProperties.get(propertyNameToSystemPropertyName(key)); } @Override public ConfigOrigin origin() { - return ConfigOrigin.JVM_PROP; + return JVM_PROP; } }