Tgofjuan opened a new issue, #15475:
URL: https://github.com/apache/dubbo/issues/15475

   ### Pre-check
   
   - [x] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   dubbo-cluster-sepcify-address-dubbo3:3.3.1
   ## Bug Description  
   There's a type inconsistency in `RpcServiceContext` class that can cause 
`NullPointerException`:  
     
   - Field `localInvoke` is declared as `Boolean` (wrapper type) with initial 
value `null`  
   - Method `setLocalInvoke(boolean localInvoke)` accepts `boolean` (primitive 
type)  
     
   ## Code Location  
   - File: 
`dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcServiceContext.java`
  
   - Field declaration: Line 60  
   - Setter method: Lines 628-630  
   
   ### Steps to reproduce this issue
   
   When trying to restore the original `localInvoke` value:  
   ```java  
   Boolean originalLocalInvoke = 
RpcContext.getServiceContext().getLocalInvoke(); // returns null  
   try {
       if (!LocalContextConfig.getServerAddress().equals(ip)) {
            RpcContext.getServiceContext().setLocalInvoke(false);
       }
       UserSpecifiedAddressUtil.setAddress(new Address(ip, port, false));
   } finally {
       // Later trying to restore:  
       RpcContext.getServiceContext().setLocalInvoke(originalLocalInvoke); // 
NPE when originalLocalInvoke is null
   }
   
   ### What you expected to happen
   
   Change the setter method to accept Boolean type: setLocalInvoke(Boolean 
localInvoke)
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: notifications-unsubscr...@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to