Skip to content

Commit f855284

Browse files
author
lucaijun
committed
AJ-551: throw error when invalid hostname
1 parent 10e7dbd commit f855284

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/com/xxdb/SimpleDBConnectionPoolConfig.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,13 @@ private static boolean isDomain(String hostName) {
167167

168168
private static boolean isIPV4(String hostName) {
169169
String regex = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$";
170-
if (hostName == null || hostName.trim().isEmpty()) {
171-
return false;
172-
}
173170
if (!hostName.matches(regex)) {
174171
return false;
175172
}
176173
String[] parts = hostName.split("\\.");
177174
try {
178175
for (String segment : parts) {
179-
if (Integer.parseInt(segment) > 255 ||
180-
(segment.length() > 1 && segment.startsWith("0"))) {
176+
if (Integer.parseInt(segment) > 255) {
181177
return false;
182178
}
183179
}

0 commit comments

Comments
 (0)