-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Fix uninitialized non-static final fields potential NPE issue in dubbo-remoting module #15602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix uninitialized non-static final fields potential NPE issue in dubbo-remoting module #15602
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #15602 +/- ##
============================================
+ Coverage 61.02% 61.06% +0.03%
- Complexity 11500 11693 +193
============================================
Files 1909 1909
Lines 86782 86783 +1
Branches 13094 13094
============================================
+ Hits 52961 52995 +34
+ Misses 28409 28372 -37
- Partials 5412 5416 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
#14848 It's different when there is multi-threading |
…ttps://github.com/zrlw/dubbo into 3.3-fixed-dubboRemoting-UninitializedFinalVariables
There was a problem hiding this 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 fixes potential NullPointerException issues in the dubbo-remoting module by addressing the initialization order of non-static final fields. The changes ensure that fields are properly initialized before they can be accessed during object construction, preventing NPEs that could occur when these fields are used in constructor chains or early method calls.
- Converts final fields to non-final and moves their initialization to appropriate methods
- Restructures timer task initialization to prevent early execution before configuration is complete
- Adds proper initialization of collections and configuration values before potential usage
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| NettyServer.java (netty4) | Moves serverShutdownTimeoutMills initialization from constructor to doOpen() method |
| NettyPortUnificationServer.java (netty4) | Initializes dubboChannels and serverShutdownTimeoutMills in doOpen0() instead of constructor |
| NettyServer.java (netty) | Adds comment clarification for channels field initialization |
| NettyPortUnificationServer.java (netty) | Moves dubboChannels initialization to doOpen0() method |
| NettyHttp3Server.java | Relocates pipelineConfigurator and serverShutdownTimeoutMills initialization to doOpen() |
| MultiMessageHandler.java | Removes unnecessary @SuppressWarnings annotation |
| AbstractClient.java | Moves connectLock initialization from field declaration to constructor |
| Timer task classes | Restructures initialization to call start() after configuration instead of in parent constructor |
| AbstractPortUnificationServer.java | Moves collection initialization to doOpen() method |
| this.hashedWheelTimer = hashedWheelTimer; | ||
| this.tick = tick; | ||
| start(); | ||
| // do not start here because inheritor should set additional timeout parameters before doing task. |
Copilot
AI
Aug 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word 'inheritor' should be 'subclass' or 'subclasses' for better clarity and standard terminology.
| // do not start here because inheritor should set additional timeout parameters before doing task. | |
| // do not start here because subclass should set additional timeout parameters before doing task. |
EarthChen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
LGTM |
…o-remoting module (apache#15602) * Fix uninitialized final variables issue in dubbo-remoting * Remove redundant initializations of AbstractPortUnificationServer fields * Change modifier of AbstractTimerTask start method --------- Co-authored-by: earthchen <[email protected]>


What is the purpose of the change?
Since the non-static final fields initialized at declaration will not be initialized during it's owner object construction, NullPointerException (NPE) will be thrown if using them during the construction just like #14848
These fields should be changed to non-final and be initialized at it's owner construction to prevent NPE.
By the way, this PR only serves as a mitigation measure. The best solution is to refactor the code by:
See details at #15600
Checklist