Skip to content

Commit

Permalink
[common]feature:use "apache.http.conn.util" replace "sun.net.util" fo…
Browse files Browse the repository at this point in the history
…r upgrading java version (#299)

Co-authored-by: Privauto <2289751443@qq.com>
  • Loading branch information
Privauto and Privauto authored Sep 20, 2022
1 parent 70d830f commit d0d2e73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@
</exclusion>
</exclusions>
</dependency>
<!-- 使用apache.http.conn.util代替sun.net.util -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
</project>
7 changes: 3 additions & 4 deletions common/src/main/java/com/usthe/common/util/IpDomainUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
package com.usthe.common.util;

import lombok.extern.slf4j.Slf4j;
import sun.net.util.IPAddressUtil;

import org.apache.http.conn.util.InetAddressUtils;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
Expand Down Expand Up @@ -60,10 +59,10 @@ public static boolean validateIpDomain(String ipDomain) {
if (LOCALHOST.equalsIgnoreCase(ipDomain)) {
return true;
}
if (IPAddressUtil.isIPv4LiteralAddress(ipDomain)) {
if (InetAddressUtils.isIPv4Address(ipDomain)) {
return true;
}
if (IPAddressUtil.isIPv6LiteralAddress(ipDomain)) {
if (InetAddressUtils.isIPv6Address(ipDomain)) {
return true;
}
return DOMAIN_PATTERN.matcher(ipDomain).matches();
Expand Down

0 comments on commit d0d2e73

Please sign in to comment.