fix: Consumer-facing API lacks nullability annotations, defeating Kotlin null-safety - #16488
Open
obabichevjb wants to merge 1 commit into
Open
obabichevjb wants to merge 1 commit into
obabichevjb wants to merge 1 commit into
Conversation
obabichevjb
force-pushed
the
kotlin-nullability-annotations
branch
from
September 28, 2026 11:42
eef68e1 to
56c4f0c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16488 +/- ##
============================================
- Coverage 60.92% 58.93% -2.00%
+ Complexity 11764 15 -11749
============================================
Files 1953 1953
Lines 89275 89275
Branches 13474 13474
============================================
- Hits 54394 52614 -1780
- Misses 29301 30964 +1663
- Partials 5580 5697 +117
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
LI123456mo
reviewed
Sep 29, 2026
This branch has not been deployed
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.
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:
Result.getValue()@NullableResult.getException()@NullableRpcContext.getAttachment(String)@Nullablenullfor an absent keyRpcContextAttachment.getAttachment(String)@Nullablenullfor an absent keyReferenceConfig.get()/get(boolean)@Nonnullnull— throws, or returns a proxyThe four
@Nullableannotations only make machine-readable a contract the Javadoc already statesin 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.Nullablecarries no JSR-305meta-annotations.
Checklist