apache/dubbo
[Bug] NetUtils.matchIpExpression(String, String) fails to parse normal IPv4 address with port
Closed
#16,308 opened on Jun 3, 2026
good first issuetype/bug
Repository metrics
- Stars
- (41,524 stars)
- PR merge metrics
- (Avg merge 7d 14h) (20 merged PRs in 30d)
Description
Pre-check
- I am sure that all the content I provide is in English.
Search before asking
- I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
Dubbo 3.3.7 , OpenJDK 17 , Ubuntu
Steps to reproduce this issue
- Add the following test case to
dubbo-common/src/test/java/org/apache/dubbo/common/utils/NetUtilsTest.java:
@Test
void testMatchIpExpressionWithIpv4AddressAndPort() throws UnknownHostException {
assertTrue(NetUtils.matchIpExpression("*.*.*.*:90", "192.168.1.63:90"));
assertTrue(NetUtils.matchIpExpression("192.168.1.*:90", "192.168.1.63:90"));
assertFalse(NetUtils.matchIpExpression("192.168.1.*:80", "192.168.1.63:90"));
}
- Run the test:
./mvnw -pl dubbo-common -Dtest=NetUtilsTest#testMatchIpExpressionWithIpv4AddressAndPort test
- The test fails because
192.168.1.63:90is treated as the host instead of being parsed into host192.168.1.63and port90.
./mvnw -pl dubbo-common -Dtest=NetUtilsTest#testMatchIpExpressionWithIpv4AddressAndPort test
What you expected to happen
NetUtils.matchIpExpression(String pattern, String address) should correctly parse a normal IPv4 address with port, such as 192.168.1.63:90, into host 192.168.1.63 and port 90.
For example:
NetUtils.matchIpExpression("*.*.*.*:90", "192.168.1.63:90")should returntrue.NetUtils.matchIpExpression("192.168.1.*:90", "192.168.1.63:90")should returntrue.NetUtils.matchIpExpression("192.168.1.*:80", "192.168.1.63:90")should returnfalse.
Anything else
This appears to be a small parsing bug in NetUtils.matchIpExpression(String, String). The fix should avoid affecting IPv6 addresses, because IPv6 addresses also contain colons.
Do you have a (mini) reproduction demo?
- Yes, I have a minimal reproduction demo to help resolve this issue more effectively!
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct