Unverified Commit 7167f292 authored by 18331247943's avatar 18331247943 Committed by GitHub
Browse files

Update StringUtils.java (#696)

资源泄漏
parent 38262e06
...@@ -217,14 +217,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { ...@@ -217,14 +217,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
*/ */
public static String getLocalCityInfo(String ip) { public static String getLocalCityInfo(String ip) {
try { try {
DataBlock dataBlock = new DbSearcher(config, file.getPath()) DbSearcher dbSearcher = new DbSearcher(config, file.getPath());
.binarySearch(ip); DataBlock dataBlock = dbSearcher.binarySearch(ip);
String region = dataBlock.getRegion(); String region = dataBlock.getRegion();
String address = region.replace("0|", ""); String address = region.replace("0|", "");
char symbol = '|'; char symbol = '|';
if (address.charAt(address.length() - 1) == symbol) { if (address.charAt(address.length() - 1) == symbol) {
address = address.substring(0, address.length() - 1); address = address.substring(0, address.length() - 1);
} }
if (dataBlock!=null){
dbSearcher.close();
}
return address.equals(ElAdminConstant.REGION) ? "内网IP" : address; return address.equals(ElAdminConstant.REGION) ? "内网IP" : address;
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment