Skip to content

Commit f578c9c

Browse files
committed
Remove system properties and envs left-over in Config tests
1 parent 12dc7c4 commit f578c9c

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

dd-trace-api/src/main/java/datadog/trace/api/Config.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ public static String getSettingFromEnvironment(final String name, final String d
600600
/** @deprecated This method should only be used internally. Use the explicit getter instead. */
601601
private static Map<String, String> getMapSettingFromEnvironment(
602602
final String name, final String defaultValue) {
603-
return parseMap(getSettingFromEnvironment(name, defaultValue), PREFIX + name);
603+
return parseMap(
604+
getSettingFromEnvironment(name, defaultValue), propertyNameToSystemPropertyName(name));
604605
}
605606

606607
/**

dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,9 @@ class ConfigTest extends Specification {
726726
727727
then:
728728
config.serviceName == "set-in-properties"
729+
730+
cleanup:
731+
System.clearProperty(PREFIX + CONFIGURATION_FILE)
729732
}
730733
731734
def "verify fallback to properties file has lower priority than system property"() {
@@ -738,6 +741,10 @@ class ConfigTest extends Specification {
738741
739742
then:
740743
config.serviceName == "set-in-system"
744+
745+
cleanup:
746+
System.clearProperty(PREFIX + CONFIGURATION_FILE)
747+
System.clearProperty(PREFIX + SERVICE_NAME)
741748
}
742749
743750
def "verify fallback to properties file has lower priority than env var"() {
@@ -750,6 +757,11 @@ class ConfigTest extends Specification {
750757
751758
then:
752759
config.serviceName == "set-in-env"
760+
761+
cleanup:
762+
System.clearProperty(PREFIX + CONFIGURATION_FILE)
763+
System.clearProperty(PREFIX + SERVICE_NAME)
764+
environmentVariables.clear("DD_SERVICE_NAME")
753765
}
754766
755767
def "verify fallback to properties file that does not exist does not crash app"() {
@@ -761,5 +773,8 @@ class ConfigTest extends Specification {
761773
762774
then:
763775
config.serviceName == 'unnamed-java-app'
776+
777+
cleanup:
778+
System.clearProperty(PREFIX + CONFIGURATION_FILE)
764779
}
765780
}

0 commit comments

Comments
 (0)