Skip to content

Fix - address declarative config warning#466

Merged
cleverchuk merged 1 commit into
mainfrom
cc/NH-123762
Apr 21, 2026
Merged

Fix - address declarative config warning#466
cleverchuk merged 1 commit into
mainfrom
cc/NH-123762

Conversation

@cleverchuk
Copy link
Copy Markdown
Contributor

@cleverchuk cleverchuk commented Apr 21, 2026

TLDR

Reorders config parsing so registered ConfigParser implementations 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:

  1. Registered parsersConfigParser implementations loaded via ServiceLoader, keyed by config name (e.g., agent.logging uses a structured parser).
  2. Type-based fallback — dispatches on ConfigProperty.getTypeClass() to call getString, getBoolean, getInt, or getLong.

Previously, the type-based parse ran unconditionally for every key, and then a separate containsKey/get check 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 via register.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 single get.

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

  1. e-1712644058766987264
  2. e-1712643928659124224
  3. e-1742334541200846848
  4. e-1777406072376840192

Copilot AI review requested due to automatic review settings April 21, 2026 13:49
@cleverchuk cleverchuk requested review from a team as code owners April 21, 2026 13:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConfigParser first (single register.get(key) + null-check) and only executes type-based parsing when absent.
  • Removes the prior unconditional type-based parse and the redundant containsKey + get double lookup.

Copy link
Copy Markdown

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown

@jerrytfleung jerrytfleung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cleverchuk cleverchuk merged commit 3a9d834 into main Apr 21, 2026
20 checks passed
@cleverchuk cleverchuk deleted the cc/NH-123762 branch April 21, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants