Skip to content

Commit 56c19f2

Browse files
committed
[新增功能](v2.5): 代码优化
1 parent f8028c8 commit 56c19f2

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@
2727
import org.slf4j.Logger;
2828
import org.slf4j.LoggerFactory;
2929
import org.springframework.core.io.ClassPathResource;
30-
3130
import javax.servlet.http.HttpServletRequest;
3231
import java.io.File;
3332
import java.io.FileNotFoundException;
34-
3533
import java.net.InetAddress;
3634
import java.net.UnknownHostException;
3735
import java.util.Calendar;
@@ -42,6 +40,7 @@
4240
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
4341
*/
4442
public class StringUtils extends org.apache.commons.lang3.StringUtils {
43+
4544
private static final Logger log = LoggerFactory.getLogger(StringUtils.class);
4645
private static boolean ipLocal = false;
4746
private static DbSearcher searcher = null;
@@ -50,20 +49,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
5049
SpringContextHolder.addCallBacks(() -> {
5150
StringUtils.ipLocal = SpringContextHolder.getProperties("ip.local-parsing", false, Boolean.class);
5251
if (ipLocal) {
53-
/**
52+
/*
5453
* 此文件为独享 ,不必关闭
5554
*/
5655
String path = "ip2region/ip2region.db";
5756
String name = "ip2region.db";
58-
DbConfig config = null;
57+
DbConfig config;
5958
try {
6059
config = new DbConfig();
6160
File file = FileUtil.inputStreamToFile(new ClassPathResource(path).getInputStream(), name);
6261
searcher = new DbSearcher(config, file.getPath());
63-
} catch (DbMakerConfigException | FileNotFoundException e) {
64-
log.error(e.getMessage(), e);
65-
} catch (NoSuchMethodException e) {
66-
log.error(e.getMessage(), e);
6762
} catch (Exception e) {
6863
log.error(e.getMessage(), e);
6964
}

0 commit comments

Comments
 (0)