fix iputil bug

This commit is contained in:
Jack 2025-07-26 17:18:47 +08:00
parent 1996e69462
commit cbdc692fe6

View File

@ -49,6 +49,9 @@ public class IpUtil implements ApplicationRunner {
try {
return searcher.search(ip);
} catch (ArrayIndexOutOfBoundsException e) {
log.error("IP{} 解析时发生数组越界异常,可能是数据文件损坏或不兼容", ip, e);
return null;
} catch (Exception e) {
String errorMsg = e.getMessage();
if (errorMsg == null) {
@ -58,7 +61,7 @@ public class IpUtil implements ApplicationRunner {
}
}
log.error("IP{} 格式错误:{}", ip, errorMsg, e);
return ip;
return null;
}
}
@ -91,6 +94,7 @@ public class IpUtil implements ApplicationRunner {
districtVo.setProvince(split.get(2)); // 设置省份
districtVo.setCity(split.get(3)); // 设置城市
} else {
log.debug("IP{} 解析结果格式不符合要求,原始数据: {}", ip, ss);
return null;
}
} catch (ArrayIndexOutOfBoundsException e) {