Skip to content

Commit 11c40a6

Browse files
author
lucaijun
committed
AJ-556: fix jdk compatibility
1 parent 85722ac commit 11c40a6

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/com/xxdb/SimpleDBConnectionPoolConfig.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5-
import sun.net.util.IPAddressUtil;
6-
75
import java.util.Objects;
86

97
public class SimpleDBConnectionPoolConfig {
@@ -155,7 +153,7 @@ private static String getNullIfEmpty(String text) {
155153
private static boolean checkHostNameValid(String hostName) {
156154
return hostName.equals("localhost") ||
157155
isIPV4(hostName) ||
158-
IPAddressUtil.isIPv6LiteralAddress(hostName) ||
156+
isIPV6(hostName) ||
159157
isDomain(hostName);
160158
}
161159

@@ -181,6 +179,37 @@ private static boolean isIPV4(String hostName) {
181179
}
182180
return true;
183181
}
182+
183+
private static boolean isIPV6(String hostName) {
184+
String regex = "(^((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4}){1}|:))"
185+
+ "|(([0-9A-Fa-f]{1,4}:){6}((:[0-9A-Fa-f]{1,4}){1}|"
186+
+ "((22[0-3]|2[0-1][0-9]|[0-1][0-9][0-9]|"
187+
+ "([0-9]){1,2})([.](25[0-5]|2[0-4][0-9]|"
188+
+ "[0-1][0-9][0-9]|([0-9]){1,2})){3})|:))|"
189+
+ "(([0-9A-Fa-f]{1,4}:){5}((:[0-9A-Fa-f]{1,4}){1,2}|"
190+
+ ":((22[0-3]|2[0-1][0-9]|[0-1][0-9][0-9]|"
191+
+ "([0-9]){1,2})([.](25[0-5]|2[0-4][0-9]|"
192+
+ "[0-1][0-9][0-9]|([0-9]){1,2})){3})|:))|"
193+
+ "(([0-9A-Fa-f]{1,4}:){4}((:[0-9A-Fa-f]{1,4}){1,3}"
194+
+ "|:((22[0-3]|2[0-1][0-9]|[0-1][0-9][0-9]|"
195+
+ "([0-9]){1,2})([.](25[0-5]|2[0-4][0-9]|[0-1][0-9][0-9]|"
196+
+ "([0-9]){1,2})){3})|:))|(([0-9A-Fa-f]{1,4}:){3}((:[0-9A-Fa-f]{1,4}){1,4}|"
197+
+ ":((22[0-3]|2[0-1][0-9]|[0-1][0-9][0-9]|"
198+
+ "([0-9]){1,2})([.](25[0-5]|2[0-4][0-9]|"
199+
+ "[0-1][0-9][0-9]|([0-9]){1,2})){3})|:))|"
200+
+ "(([0-9A-Fa-f]{1,4}:){2}((:[0-9A-Fa-f]{1,4}){1,5}|"
201+
+ ":((22[0-3]|2[0-1][0-9]|[0-1][0-9][0-9]|"
202+
+ "([0-9]){1,2})([.](25[0-5]|2[0-4][0-9]|"
203+
+ "[0-1][0-9][0-9]|([0-9]){1,2})){3})|:))"
204+
+ "|(([0-9A-Fa-f]{1,4}:){1}((:[0-9A-Fa-f]{1,4}){1,6}"
205+
+ "|:((22[0-3]|2[0-1][0-9]|[0-1][0-9][0-9]|"
206+
+ "([0-9]){1,2})([.](25[0-5]|2[0-4][0-9]|"
207+
+ "[0-1][0-9][0-9]|([0-9]){1,2})){3})|:))|"
208+
+ "(:((:[0-9A-Fa-f]{1,4}){1,7}|(:[fF]{4}){0,1}:((22[0-3]|2[0-1][0-9]|"
209+
+ "[0-1][0-9][0-9]|([0-9]){1,2})"
210+
+ "([.](25[0-5]|2[0-4][0-9]|[0-1][0-9][0-9]|([0-9]){1,2})){3})|:)))$)";
211+
return hostName.matches(regex);
212+
}
184213
}
185214

186215

0 commit comments

Comments
 (0)