Skip to content

Rename field to prevent any missunderstanding clash#12574

Open
sdelamo wants to merge 3 commits into
5.0.xfrom
rename-field-to-prevent-any-missunderstanding-clash
Open

Rename field to prevent any missunderstanding clash#12574
sdelamo wants to merge 3 commits into
5.0.xfrom
rename-field-to-prevent-any-missunderstanding-clash

Conversation

@sdelamo
Copy link
Copy Markdown
Member

@sdelamo sdelamo commented Mar 26, 2026

I am not sure I like this change, but it satisfies Sonar's complaints about name clashes.

Copilot AI review requested due to automatic review settings March 26, 2026 11:18
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

This PR renames several public constants to avoid naming clashes flagged by Sonar, updating usages across core binders and graceful shutdown configuration.

Changes:

  • Renamed ArgumentBinder.BindingResult constants (EMPTY, UNSATISFIED) to more specific names and updated call sites.
  • Renamed GracefulShutdownConfiguration.ENABLED constant to a longer, more explicit identifier and updated @Requires usage + tests.
  • Updated multiple test binders/specs to reference the renamed constants.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
websocket/src/main/java/io/micronaut/websocket/bind/WebSocketStateBinderRegistry.java Updates binder to use renamed BindingResult unsatisfied constant.
http/src/main/java/io/micronaut/http/bind/binders/RequestBeanAnnotationBinder.java Updates empty binding result constant usage.
http/src/main/java/io/micronaut/http/bind/binders/DefaultUnmatchedRequestArgumentBinder.java Updates comparison against unsatisfied binding result constant.
http-server/src/main/java/io/micronaut/http/server/binding/LocaleArgumentBinder.java Updates unsatisfied binding result constant usage.
http-server/src/main/java/io/micronaut/http/server/binding/BasicAuthArgumentBinder.java Updates empty binding result constant usage.
http-server-netty/src/main/java/io/micronaut/http/server/netty/binders/NettyRequestArgumentBinder.java Updates empty binding result constant usage.
core/src/main/java/io/micronaut/core/bind/ArgumentBinder.java Renames BindingResult constants and updates factory methods accordingly.
websocket/src/main/java/io/micronaut/websocket/bind/WebSocketStateBinderRegistry.java Adjusts binding return to use renamed unsatisfied constant.
context/src/main/java/io/micronaut/runtime/graceful/GracefulShutdownListener.java Updates @Requires(property=...) to renamed configuration constant.
context/src/main/java/io/micronaut/runtime/graceful/GracefulShutdownConfiguration.java Renames the exported enabled-property constant.
management/src/test/groovy/io/micronaut/management/health/indicator/GracefulShutdownContextSpec.groovy Updates test configuration map to use the renamed shutdown enabled constant.
test-suite/src/test/java/io/micronaut/docs/http/server/bind/annotation/ShoppingCartRequestArgumentBinder.java Updates empty binding result constant usage in test binder.
test-suite/src/test/groovy/io/micronaut/upload/PrincipalBinder.java Updates empty binding result constant usage in test binder.
test-suite-kotlin/src/test/kotlin/io/micronaut/docs/http/server/bind/annotation/ShoppingCartRequestArgumentBinder.kt Updates empty binding result constant usage in test binder (Kotlin).
test-suite-groovy/src/test/groovy/io/micronaut/docs/http/server/bind/type/ShoppingCartRequestArgumentBinder.groovy Updates empty binding result constant usage in test binder (Groovy).
test-suite-groovy/src/test/groovy/io/micronaut/docs/http/server/bind/annotation/ShoppingCartRequestArgumentBinder.groovy Updates empty binding result constant usage in test binder (Groovy).
core/src/test/groovy/io/micronaut/core/bind/ExecutableBinderSpec.groovy Updates tests to use renamed unsatisfied binding result constant.

* An empty but satisfied result.
*/
BindingResult EMPTY = Optional::empty;
BindingResult BINDING_RESULT_EMPTY = Optional::empty;
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Renaming BindingResult.EMPTY and BindingResult.UNSATISFIED to new identifiers is a source/binary breaking change for any external code referencing those public constants. To preserve compatibility (and still satisfy Sonar), keep the old constant names as @Deprecated aliases that delegate to the new constants (e.g., EMPTY = BINDING_RESULT_EMPTY and UNSATISFIED = BINDING_RESULT_UNSATISFIED), while encouraging internal usage of the new names.

Copilot uses AI. Check for mistakes.
* An empty but unsatisfied result.
*/
BindingResult UNSATISFIED = new BindingResult() {
BindingResult BINDING_RESULT_UNSATISFIED = new BindingResult() {
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Renaming BindingResult.EMPTY and BindingResult.UNSATISFIED to new identifiers is a source/binary breaking change for any external code referencing those public constants. To preserve compatibility (and still satisfy Sonar), keep the old constant names as @Deprecated aliases that delegate to the new constants (e.g., EMPTY = BINDING_RESULT_EMPTY and UNSATISFIED = BINDING_RESULT_UNSATISFIED), while encouraging internal usage of the new names.

Copilot uses AI. Check for mistakes.
*/
static <R> BindingResult<R> empty() {
return BindingResult.EMPTY;
return BindingResult.BINDING_RESULT_EMPTY;
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Renaming BindingResult.EMPTY and BindingResult.UNSATISFIED to new identifiers is a source/binary breaking change for any external code referencing those public constants. To preserve compatibility (and still satisfy Sonar), keep the old constant names as @Deprecated aliases that delegate to the new constants (e.g., EMPTY = BINDING_RESULT_EMPTY and UNSATISFIED = BINDING_RESULT_UNSATISFIED), while encouraging internal usage of the new names.

Copilot uses AI. Check for mistakes.
*/
static <R> BindingResult<R> unsatisfied() {
return UNSATISFIED;
return BINDING_RESULT_UNSATISFIED;
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Renaming BindingResult.EMPTY and BindingResult.UNSATISFIED to new identifiers is a source/binary breaking change for any external code referencing those public constants. To preserve compatibility (and still satisfy Sonar), keep the old constant names as @Deprecated aliases that delegate to the new constants (e.g., EMPTY = BINDING_RESULT_EMPTY and UNSATISFIED = BINDING_RESULT_UNSATISFIED), while encouraging internal usage of the new names.

Copilot uses AI. Check for mistakes.
public final class GracefulShutdownConfiguration implements Toggleable {
public static final String PREFIX = "micronaut.lifecycle.graceful-shutdown";
public static final String ENABLED = PREFIX + ".enabled";
public static final String MICRONAUT_LIFECYCLE_GRACEFUL_SHUTDOWN_ENABLED = PREFIX + ".enabled";
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Renaming the public constant GracefulShutdownConfiguration.ENABLED to MICRONAUT_LIFECYCLE_GRACEFUL_SHUTDOWN_ENABLED is also a breaking change for downstream code that references this constant (common in @Requires(property=...) usage). Consider retaining ENABLED as an @Deprecated alias to the new constant to avoid breaking consumers, while using the new constant internally.

Suggested change
public static final String MICRONAUT_LIFECYCLE_GRACEFUL_SHUTDOWN_ENABLED = PREFIX + ".enabled";
public static final String MICRONAUT_LIFECYCLE_GRACEFUL_SHUTDOWN_ENABLED = PREFIX + ".enabled";
/**
* @deprecated Use {@link #MICRONAUT_LIFECYCLE_GRACEFUL_SHUTDOWN_ENABLED} instead.
*/
@Deprecated
public static final String ENABLED = MICRONAUT_LIFECYCLE_GRACEFUL_SHUTDOWN_ENABLED;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants