Rename field to prevent any missunderstanding clash#12574
Conversation
There was a problem hiding this comment.
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.BindingResultconstants (EMPTY,UNSATISFIED) to more specific names and updated call sites. - Renamed
GracefulShutdownConfiguration.ENABLEDconstant to a longer, more explicit identifier and updated@Requiresusage + 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; |
There was a problem hiding this comment.
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.
| * An empty but unsatisfied result. | ||
| */ | ||
| BindingResult UNSATISFIED = new BindingResult() { | ||
| BindingResult BINDING_RESULT_UNSATISFIED = new BindingResult() { |
There was a problem hiding this comment.
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.
| */ | ||
| static <R> BindingResult<R> empty() { | ||
| return BindingResult.EMPTY; | ||
| return BindingResult.BINDING_RESULT_EMPTY; |
There was a problem hiding this comment.
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.
| */ | ||
| static <R> BindingResult<R> unsatisfied() { | ||
| return UNSATISFIED; | ||
| return BINDING_RESULT_UNSATISFIED; |
There was a problem hiding this comment.
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.
| 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"; |
There was a problem hiding this comment.
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.
| 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; |
I am not sure I like this change, but it satisfies Sonar's complaints about name clashes.