Fix - address declarative config warning#466
Merged
Merged
Conversation
…unused parse result warning
Contributor
There was a problem hiding this comment.
Pull request overview
Restructures DeclarativeConfigParser.parse() to prioritize registered ConfigParser implementations before falling back to type-based parsing, eliminating a dead/overwritten intermediate parse result (and the associated unused-result warning).
Changes:
- Looks up a registered
ConfigParserfirst (singleregister.get(key)+ null-check) and only executes type-based parsing when absent. - Removes the prior unconditional type-based parse and the redundant
containsKey+getdouble lookup.
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.
TLDR
Reorders config parsing so registered
ConfigParserimplementations are checked before the type-based fallback, eliminating a dead intermediate assignment that produced an unused-result warning.Technical Details
DeclarativeConfigParser.parse()iterates over YAML config keys and resolves each to a value. Two parsing strategies exist:ConfigParserimplementations loaded viaServiceLoader, keyed by config name (e.g.,agent.logginguses a structured parser).ConfigProperty.getTypeClass()to callgetString,getBoolean,getInt, orgetLong.Previously, the type-based parse ran unconditionally for every key, and then a separate
containsKey/getcheck on the parser registry would overwrite the result. This meant the type-based conversion could trigger a warning for some keys when there's a type-mismatch. This change avoids it by using the config parser first which handles structured types.The fix restructures the logic into a single
if/else: look up the registered parser first viaregister.get(key)with a null-check, and only fall back to type-based parsing when no registered parser exists. This also collapses the prior double map lookup (containsKey+get) into a singleget.Behavior is unchanged — registered parsers always took precedence, and they still do. The difference is that the type-based branch no longer executes when it would be immediately overwritten.
Test services data