obabichevjb opened a new pull request, #16488: URL: https://github.com/apache/dubbo/pull/16488
## What is the purpose of the change? Fixes #16487 Dubbo's most-travelled consumer entry points carry no nullability annotation, so Kotlin models their returns as *platform types* and relaxes null-checking at that boundary. This compiles today with zero warnings, and fails at runtime: This PR annotates five methods so the compiler rejects that instead: | Method | Annotation | Basis | |---|---|---| | `Result.getValue()` | `@Nullable` | Javadoc already states *"if no result return null"* | | `Result.getException()` | `@Nullable` | Javadoc already states *"if no exception return null"* | | `RpcContext.getAttachment(String)` | `@Nullable` | returns `null` for an absent key | | `RpcContextAttachment.getAttachment(String)` | `@Nullable` | returns `null` for an absent key | | `ReferenceConfig.get()` / `get(boolean)` | `@Nonnull` | never returns `null` — throws, or returns a proxy | The four `@Nullable` annotations only make machine-readable a contract the Javadoc already states in prose. `ReferenceConfig.get()` is the inverse case: a platform type that is in fact never null, so Kotlin users lose type information for no reason at the most-used call site in the API. Annotating with Dubbo's own annotation would have **no effect on Kotlin callers**. Kotlin honours a fixed set of nullability annotations, and `common.lang.Nullable` carries no JSR-305 meta-annotations. ## Checklist - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project. - [x] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](../CONTRIBUTING.md) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
