salmaloel657-dotcom commented on issue #10207: URL: https://github.com/apache/rocketmq/issues/10207#issuecomment-4141915360
Thanks for bringing this up On Wed, Mar 25, 2026, 6:14 AM Guimu ***@***.***> wrote: > *daguimu* created an issue (apache/rocketmq#10207) > <https://github.com/apache/rocketmq/issues/10207> > Before Creating the Bug Report > > - I found a bug, not just asking a question, which should be created > in GitHub Discussions <https://github.com/apache/rocketmq/discussions>. > - I have searched the GitHub Issues > <https://github.com/apache/rocketmq/issues> and GitHub Discussions > <https://github.com/apache/rocketmq/discussions> of this repository > and believe that this is not a duplicate. > - I have confirmed that this bug belongs to the current repository, > not other repositories of RocketMQ. > > Runtime platform environment > > All platforms > RocketMQ version > > develop branch (latest) > JDK Version > > All > Describe the Bug > > In DefaultHAConnection (line 64) and AutoSwitchHAConnection (line 109), > .toString() is called directly on the return value of > getRemoteSocketAddress() without a null check: > > this.clientAddress = this.socketChannel.socket().getRemoteSocketAddress().toString(); > > According to the Java documentation, Socket.getRemoteSocketAddress() > returns null if the socket is not connected. In edge cases (e.g., the > socket is accepted but the remote peer disconnects before the HA connection > constructor completes), this can throw a NullPointerException, which > would crash the HA connection setup. > Steps to Reproduce > > 1. Under network instability, a slave connects and immediately > disconnects > 2. The master accepts the socket channel > 3. DefaultHAConnection constructor is called > 4. getRemoteSocketAddress() returns null because the peer has already > disconnected > 5. .toString() on null throws NPE > > What Did You Expect to See? > > The HA connection should handle null remote address gracefully. > What Did You See Instead? > > NullPointerException in the HA connection constructor. > Additional Context > > Affected files: > > - > store/src/main/java/org/apache/rocketmq/store/ha/DefaultHAConnection.java:64 > - > store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAConnection.java:109 > > — > Reply to this email directly, view it on GitHub > <https://github.com/apache/rocketmq/issues/10207?email_source=notifications&email_token=CABFFMJZMEFCKOEDRE3P6CL4SO5PVA5CNFSL4Z3JMQ5C6L3HNF2C22DVMIXUS43TOVSS6NBRGM2DKOJRGA4DRJTSMVQXG33OVJZXKYTTMNZGSYTFMSSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/CABFFMKFPIL4QQKA2RTBSVT4SO5PVAVCNFSM6AAAAACW6XIYROVHI2DSMVQWIX3LMV43ASLTON2WKOZUGEZTINJZGEYDQOA> > . > You are receiving this because you are subscribed to this thread.Message > ID: ***@***.***> > -- 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]
