6mmLIU opened a new issue, #15658:
URL: https://github.com/apache/dubbo/issues/15658

   ### 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 feature requirement.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Descriptions
   
   ### Summary
   Add an overload `StringUtils.isNumeric(String str, boolean allowDot, boolean 
allowSign)` to optionally allow a single leading `+` or `-` while keeping the 
existing API and behavior unchanged.
   
   ### Motivation
   Some call sites need to accept signed integers/decimals (e.g., `-1`, 
`+1.23`). The current `isNumeric(String, boolean allowDot)` rejects any leading 
sign, which leads to ad-hoc checks or rejecting valid inputs. Centralizing this 
logic in `StringUtils` reduces duplication and avoids subtle bugs.
   
   ### Proposed change
   - Introduce `isNumeric(String, boolean allowDot, boolean allowSign)`.
   - When `allowSign == true`, accept **one** leading sign at index 0.
   - A lone sign (`"+"` or `"-"`) remains invalid.
   - Dot rule unchanged: at most one dot if `allowDot == true`; otherwise any 
dot fails.
   - Only ASCII digits are recognized; no scientific notation, whitespace 
trimming, or locale digits.
   
   ### Compatibility
   - **Strictly backward compatible**: the original method and its semantics 
remain intact; existing callers observe no behavior change.
   
   ### Affected component
   - Module: `dubbo-common`
   - Class: `org.apache.dubbo.common.utils.StringUtils`
   
   ### Test plan
   Add unit tests covering:
   - Signed/unsigned integers and decimals.
   - Lone sign (`"+"`, `"-"`) → invalid.
   - Multiple dots, embedded non-digits, null/empty strings → invalid.
   - Regression checks that the original method still returns `false` for 
signed inputs.
   
   ### CI note
   Run `mvn -q -pl dubbo-common -am test` in a networked environment so the 
parent POM and dependencies can be resolved.
   
   
   ### Related issues
   
   None found after searching for “StringUtils.isNumeric” / “allow sign” / 
“signed number”.
   This issue will be referenced by the upcoming PR.
   
   
   ### 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