Skip to content

Commit 3ac750f

Browse files
committed
relaxing restraint on rereportToCollector
1 parent 6d0f52d commit 3ac750f

File tree

2 files changed

+2
-35
lines changed

2 files changed

+2
-35
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ static <T> ConfigValueResolver<T> of(T value, ConfigOrigin origin, int seqId, St
653653

654654
/** Re-reports this resolved value to ConfigCollector with the specified seqId */
655655
void reReportToCollector(String key, int finalSeqId) {
656-
if (value != null && origin != null) {
656+
// Source and value should never be null if there is an initialized ConfigValueResolver
657+
if (origin != null) {
657658
ConfigCollector.get().put(key, value, origin, finalSeqId, configId);
658659
}
659660
}

internal-api/src/test/groovy/datadog/trace/bootstrap/config/provider/ConfigProviderTest.groovy

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -139,40 +139,6 @@ class ConfigProviderTest extends DDSpecification {
139139
"getDouble" | "test.double" | "DD_TEST_DOUBLE"| "42.75" | "notADouble" | 2.71 | 42.75 | { configProvider, key, defVal -> configProvider.getDouble(key, defVal) }
140140
}
141141

142-
def "ConfigProvider does not report final result when conditions are not met"() {
143-
setup:
144-
ConfigCollector.get().collect() // clear previous state
145-
146-
// Set up different combinations that should NOT trigger re-reporting
147-
if (injectEnv) {
148-
injectEnvConfig("DD_TEST_MAP", envValue)
149-
}
150-
if (injectJvm) {
151-
injectSysConfig("test.map", jvmValue)
152-
}
153-
154-
def provider = ConfigProvider.createDefault()
155-
156-
when:
157-
def result = provider.getMergedMap("test.map")
158-
def collected = ConfigCollector.get().collect()
159-
160-
then:
161-
// Should NOT have a CALCULATED entry because conditions to re-report have not been met:
162-
def calculatedSettings = collected.get(ConfigOrigin.CALCULATED)
163-
calculatedSettings == null || !calculatedSettings.containsKey("test.map")
164-
165-
// Verify the result matches expectations
166-
result == [:]
167-
168-
where:
169-
injectEnv | injectJvm | envValue | jvmValue
170-
false | false | null | null
171-
true | false | "" | null
172-
false | true | null | " "
173-
true | true | "" | ""
174-
}
175-
176142
def "ConfigProvider transforms invalid values for getBoolean to false with CALCULATED origin"() {
177143
// Booleans are a special case; we currently treat all invalid boolean configurations as false rather than falling back to a lower precedence setting.
178144
setup:

0 commit comments

Comments
 (0)