Internal - Specialize ConfigParser for declarative configuration parser SPI - #558
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the declarative YAML configuration parser SPI by introducing a dedicated, properly typed service interface (DeclarativeConfigPropertyParser) and migrating all declarative YAML parsers and their consumer to use it, eliminating prior raw-type/unchecked-cast workarounds and enabling removal of a global -Xlint:-processing suppression in the shared Java conventions plugin.
Changes:
- Add
DeclarativeConfigPropertyParseras a specialized SPI (ConfigParser<DeclarativeConfigProperties, Object>) for declarative configuration property parsers. - Update all declarative YAML parser implementations to register via
@AutoService(DeclarativeConfigPropertyParser.class)and implement the new interface. - Update the
ServiceLoaderconsumer to load the new SPI directly, and remove-Xlint:-processingfrom shared Java compilation conventions.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/DeclarativeConfigPropertyParser.java | Introduces the dedicated, correctly-typed SPI for declarative config property parsing. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/DeclarativeConfigParser.java | Loads DeclarativeConfigPropertyParser via ServiceLoader and removes the prior unchecked cast path. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/UrlSampleRateConfigParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/TriggerTraceParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/TransactionSettingsConfigParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/TransactionNamingSchemesParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/TracingModeParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/StacktraceFilterParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/SqlTagDatabasesParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/SqlQueryMaxLengthParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/ProxyParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/LogSettingParser.java | Migrates SPI registration and implementation to the new declarative parser SPI. |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/parser/yaml/ProfilingSettingsParser.java | Migrates SPI registration and implementation (in custom) to the new declarative parser SPI. |
| buildSrc/src/main/kotlin/solarwinds.java-conventions.gradle.kts | Removes -Xlint:-processing now that the motivating raw-type processing warnings are eliminated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Replaces the raw
ConfigParserSPI registration used by declarative YAMLconfig parsers with a dedicated, properly-typed marker interface,
DeclarativeConfigPropertyParser. This removes two@SuppressWarningsworkarounds that existed solely because the SPI type was raw, and allows
dropping the module-wide
-Xlint:-processingsuppression from the Javaconventions plugin.
Background
ConfigParser<T, R>is a generic conversion interface used across theconfig system. The declarative YAML parsers all specialize it to
ConfigParser<DeclarativeConfigProperties, R>for variousR, but wereregistered for discovery via
@AutoService(ConfigParser.class)— i.e.against the raw generic type rather than a concrete parameterization.
That raw registration had two costs:
@SuppressWarnings("rawtypes")to compilecleanly under
-Xlint:all -Werror.ServiceLoader.load(ConfigParser.class, ...), got back rawConfigParserinstances and had to unchecked-cast each one toConfigParser<DeclarativeConfigProperties, Object>before it could bestored in its typed registry map.
were being blanket-suppressed project-wide via
-Xlint:-processinginthe shared Java conventions plugin, which also silenced any other
unrelated processing warnings from any module using that convention.
Change
Introduces
DeclarativeConfigPropertyParser, an interface that fixes thegeneric parameters:
ConfigParser<DeclarativeConfigProperties, Object>.All 11 YAML declarative config parsers (profiling settings, logging,
proxy, SQL query max length, SQL tag databases, stacktrace filters,
tracing mode, transaction naming schemes, transaction settings, trigger
trace, URL sample rate) now implement this interface directly instead of
ConfigParser<DeclarativeConfigProperties, R>, and register via@AutoService(DeclarativeConfigPropertyParser.class)instead of@AutoService(ConfigParser.class).The consumer's
ServiceLoader.load(...)call is updated to loadDeclarativeConfigPropertyParserdirectly, so the loaded instances arealready correctly typed for the registry map — no cast needed.
With the raw-type usage gone, the underlying annotation-ownership warning
no longer fires, so
-Xlint:-processingis removed from the shared Javaconventions plugin — tightening lint enforcement for every module built
with that plugin, not just this one.
Why this approach
Rather than suppressing the warnings at each of the 11 call sites (or
leaving the project-wide
-Xlintescape hatch in place), narrowing theSPI contract to a single, correctly-typed interface eliminates the root
cause: the type system now reflects that every implementer of this SPI is
a
DeclarativeConfigProperties-to-Objectparser, so no raw type orunchecked cast is ever necessary to satisfy that contract.
Verification
compileJavapasses under-Werror, confirming the-Xlint:-processingremoval doesn't surface new lint failures anywhereelse in the build.
suite pass unchanged.
META-INF/servicesoutput that all 11 parsersare registered under the new SPI type, with none left registered under
the old one.
No functional or behavioral change — this is purely an SPI-typing and
lint-cleanliness improvement.
Test services data