Fix IPv4 address port parsing in NetUtils#16309
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16309 +/- ##
============================================
+ Coverage 60.77% 60.81% +0.03%
- Complexity 11768 11772 +4
============================================
Files 1953 1953
Lines 89196 89203 +7
Branches 13457 13458 +1
============================================
+ Hits 54212 54245 +33
+ Misses 29418 29397 -21
+ Partials 5566 5561 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
71a360b to
b63b256
Compare
|
The failed Samples Test seems caused by Docker Hub timeout while pulling |
|
Thanks for the review! |
RainYuY
left a comment
There was a problem hiding this comment.
LGTM,But I think a better way is to directly deprecate this method. In fact, we have a three-parameter method that supports normal calls, just migrate the calls from mesh over
eaf184c to
f676cf9
Compare
Deprecate the two-argument NetUtils.matchIpExpression method and migrate mesh address matching to the existing three-argument overload so IPv4 host:port inputs are matched with a separated port. Fixes apache#16308
f676cf9 to
638cc67
Compare
|
Thanks for the suggestion😊, I updated the PR to deprecate the two-argument method and migrated the mesh AddressMatch usage to the three-argument matchIpExpression API. I also added AddressMatch tests to cover IPv4 host:port matching, port mismatch, and IPv6 matching. And I noticed the field/method name is currently If needed, I can handle the naming cleanup in a separate PR while keeping backward-compatible getCird/setCird methods. |
Fixes #16308
What is the purpose of the change?
This PR fixes
NetUtils.matchIpExpression(String, String)so it can correctly parse normal IPv4host:portaddresses, such as192.168.1.63:90.Previously, the method only split the address when it ended with
:, so a normal IPv4 address with port was treated as the full host string and could fail withUnknownHostException.The fix parses the address only when it contains exactly one colon, avoiding impact on IPv6 addresses.
Checklist