Skip to content

Fix IPv4 address port parsing in NetUtils#16309

Open
yin-bo-Final wants to merge 1 commit into
apache:3.3from
yin-bo-Final:fix-netutils-ipv4-address-port
Open

Fix IPv4 address port parsing in NetUtils#16309
yin-bo-Final wants to merge 1 commit into
apache:3.3from
yin-bo-Final:fix-netutils-ipv4-address-port

Conversation

@yin-bo-Final
Copy link
Copy Markdown

Fixes #16308

What is the purpose of the change?

This PR fixes NetUtils.matchIpExpression(String, String) so it can correctly parse normal IPv4 host:port addresses, such as 192.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 with UnknownHostException.

The fix parses the address only when it contains exactly one colon, avoiding impact on IPv6 addresses.

Checklist

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.81%. Comparing base (ee9c190) to head (638cc67).

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     
Flag Coverage Δ
integration-tests-java21 32.17% <0.00%> (+0.06%) ⬆️
integration-tests-java8 32.24% <0.00%> (-0.01%) ⬇️
samples-tests-java21 32.15% <0.00%> (-0.03%) ⬇️
samples-tests-java8 29.74% <0.00%> (-0.12%) ⬇️
unit-tests-java11 59.02% <100.00%> (-0.03%) ⬇️
unit-tests-java17 58.51% <100.00%> (+<0.01%) ⬆️
unit-tests-java21 58.51% <100.00%> (+0.02%) ⬆️
unit-tests-java25 58.48% <100.00%> (+0.07%) ⬆️
unit-tests-java8 59.03% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yin-bo-Final yin-bo-Final force-pushed the fix-netutils-ipv4-address-port branch 2 times, most recently from 71a360b to b63b256 Compare June 3, 2026 10:50
@yin-bo-Final
Copy link
Copy Markdown
Author

The failed Samples Test seems caused by Docker Hub timeout while pulling eclipse-temurin:21-jdk and mysql:5.7.40.

zrlw
zrlw previously approved these changes Jun 5, 2026
Copy link
Copy Markdown
Contributor

@zrlw zrlw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yin-bo-Final
Copy link
Copy Markdown
Author

Thanks for the review!

RainYuY
RainYuY previously approved these changes Jun 5, 2026
Copy link
Copy Markdown
Member

@RainYuY RainYuY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@yin-bo-Final yin-bo-Final dismissed stale reviews from RainYuY and zrlw via eaf184c June 5, 2026 02:39
@yin-bo-Final yin-bo-Final force-pushed the fix-netutils-ipv4-address-port branch 2 times, most recently from eaf184c to f676cf9 Compare June 5, 2026 02:45
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
@yin-bo-Final yin-bo-Final force-pushed the fix-netutils-ipv4-address-port branch from f676cf9 to 638cc67 Compare June 5, 2026 02:49
@yin-bo-Final
Copy link
Copy Markdown
Author

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 cird, which looks like a typo of cidr🤔, but I kept it unchanged in this PR to avoid introducing an unrelated compatibility change.

If needed, I can handle the naming cleanup in a separate PR while keeping backward-compatible getCird/setCird methods.

@yin-bo-Final yin-bo-Final requested review from RainYuY and zrlw June 5, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] NetUtils.matchIpExpression(String, String) fails to parse normal IPv4 address with port

4 participants