Kris20030907 opened a new issue, #10025:
URL: https://github.com/apache/rocketmq/issues/10025

   ### Before Creating the Enhancement Request
   
   - [x] I have confirmed that this should be classified as an enhancement 
rather than a bug/feature.
   
   
   ### Summary
   
   When initializing ProxyConfig, if localServeAddr is mistakenly set to a few 
empty characters by the user, such as localServerAddr="   ", it will cause an 
exception 'get local serve ip failed' to be thrown. The real reason is simply a 
configuration error, which can mislead troubleshooting.
   
   ### Motivation
   
   enhance config check
   
   ### Describe the Solution You'd Like
   
   Uniformly use the isBlanck method, which supports checking for null and a 
length of 0, and can completely replace the isEmpty method.
   
   ### Describe Alternatives You've Considered
   
   A clearer way to write:
   ```java
   if (StringUtils.isBlank(localServeAddr)) {
           this.localServeAddr = NetworkUtil.getLocalAddress();
           if (StringUtils.isBlank(localServeAddr)) {
               throw new 
ProxyException(ProxyExceptionCode.INTERNAL_SERVER_ERROR, 
                                      "failed to get local IP address");
           }
       }
   ```
   
   ### Additional Context
   
   detail:
   - config:
   ```properties
   localServeAddr=    # has several blank
   or
   localServeAddr=\t
   ```
   - config init logic
   ```java
   private String localServeAddr = "   ";  // from config file
   
   if (StringUtils.isEmpty(localServeAddr)) {  // false! "   ".length() > 0 and 
!= null
       // skip, failed to retrieve the local address
   }
   if (StringUtils.isBlank(localServeAddr)) {   // true!
       throw new ProxyException(...);  // Throws an exception
   }
   ```
   
   This may lead the user to mistakenly believe there is a network issue.


-- 
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]

Reply via email to