fix iputil bug
This commit is contained in:
parent
1996e69462
commit
cbdc692fe6
@ -49,6 +49,9 @@ public class IpUtil implements ApplicationRunner {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return searcher.search(ip);
|
return searcher.search(ip);
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
log.error("IP:{} 解析时发生数组越界异常,可能是数据文件损坏或不兼容", ip, e);
|
||||||
|
return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String errorMsg = e.getMessage();
|
String errorMsg = e.getMessage();
|
||||||
if (errorMsg == null) {
|
if (errorMsg == null) {
|
||||||
@ -58,7 +61,7 @@ public class IpUtil implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.error("IP:{} 格式错误:{}", ip, errorMsg, e);
|
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.setProvince(split.get(2)); // 设置省份
|
||||||
districtVo.setCity(split.get(3)); // 设置城市
|
districtVo.setCity(split.get(3)); // 设置城市
|
||||||
} else {
|
} else {
|
||||||
|
log.debug("IP:{} 解析结果格式不符合要求,原始数据: {}", ip, ss);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user