Skip to content

Commit 535c685

Browse files
committed
relaxing reReportToCollector restraint and adding unit test
1 parent 3ac750f commit 535c685

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ private static <T> void reportDefault(String key, T defaultValue) {
627627
}
628628

629629
/** Helper class to store resolved configuration values with their metadata */
630-
private static class ConfigValueResolver<T> {
630+
static class ConfigValueResolver<T> {
631631
final T value;
632632
final ConfigOrigin origin;
633633
final int seqId;

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,4 +475,17 @@ class ConfigProviderTest extends DDSpecification {
475475
def maxSeqId = [defaultSetting.seqId, envSetting.seqId, jvmSetting.seqId, calculatedSetting.seqId].max()
476476
calculatedSetting.seqId == maxSeqId
477477
}
478+
479+
// NOTE: This is a case that SHOULD never occur. #reReportToCollector(String, int) should only be called with valid origins
480+
def "ConfigValueResolver reReportToCollector handles null origin gracefully"() {
481+
setup:
482+
ConfigCollector.get().collect() // clear previous state
483+
ConfigProvider.ConfigValueResolver resolver = ConfigProvider.ConfigValueResolver.of("1")
484+
485+
when:
486+
resolver.reReportToCollector("test.key", 5)
487+
488+
then:
489+
0 * ConfigCollector.get().put(_, _, _, _, _)
490+
}
478491
}

0 commit comments

Comments
 (0)