Configure jsonSchema2Pojo to not initialize collections#8356
Conversation
| Arguments.of(new ViewStreamModel().withAttributeKeys(null), View.builder().build()), | ||
| // attribute_keys with only included (no excluded) - reproduces | ||
| // https://github.com/open-telemetry/opentelemetry-java/issues/8337 | ||
| Arguments.of( |
There was a problem hiding this comment.
This new test case fails without the change to build.gradle.kts.
Refactored these tests to follow the parameterized test pattern used elsewhere in these declarative config factory tests.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8356 +/- ##
============================================
+ Coverage 90.82% 90.85% +0.03%
- Complexity 7927 7936 +9
============================================
Files 895 895
Lines 23872 23872
Branches 2378 2378
============================================
+ Hits 21681 21690 +9
Misses 1446 1446
+ Partials 745 736 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
breedx-splk
left a comment
There was a problem hiding this comment.
Looks like a good change to me. I didn't see explicitly in the tests where the null case would be covered. Is that something that is still lacking after this PR?
Is there any concern about existing code assuming non-null because of prior behavior?
|
This issue also impacts the rule-based sampler and resource attribute detectors, as they both get empty collections where a While on the java-side, having an For example, from the resource detector in kitchen sink example: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/snippets/Resource_kitchen_sink.yaml resource:
# SNIPPET_START
attributes:
detection/development:
attributes:
included:
- process.*
excluded:
- process.command_args
detectors:
- process:Here removing one of Same with rule-based sampler, the following configuration currently fails if we remove any of the tracer_provider:
processors:
- simple:
exporter:
console:
sampler:
composite/development:
rule_based:
rules:
- attribute_patterns:
key: http.path
included:
- /internal/*
excluded:
- /internal/special/* |
I did an analysis of all the cases where declarative config has arrays and all the interpretation logic has null checks already, so this shouldn't be a problem |
| Arguments.of( | ||
| new ViewStreamModel() | ||
| .withAttributeKeys( | ||
| new IncludeExcludeModel() |
There was a problem hiding this comment.
Looks like a good change to me. I didn't see explicitly in the tests where the null case would be covered. Is that something that is still lacking after this PR?
@breedx-splk Here's the null case test. Previously, omitting withExcluded would mean it initializes with new ArrayList<>(), now it initializes to null
Fixes #8337.
Currently, all collection types in generated pojos initialize to
new ArrayList<>(). This prevents us from being able to differentiate between null and empty, which is key to implementing declarative config semantics.