1.5K Star 7.7K Fork 1.9K

GVP狮子的魂 / ip2region

 / 详情

arraycopy: source index -15407511 out of bounds for byte[17498059]

待办的
创建于  
2023-03-08 17:02

` static {
/*
* 此文件为独享 ,不必关闭
*/
String path = "ip2region/ip2region.xdb";
String name = "ip2region.xdb";
try {
byte[] cBuff = Searcher.loadContentFromFile(FileUtil.inputStreamToFile(new ClassPathResource(path).getInputStream(), name).getPath());
// File file = FileUtil.inputStreamToFile(new ClassPathResource(path).getInputStream(), name);

// dbSearcher = Searcher.newWithBuffer(FileUtil.getByte(file));
dbSearcher = Searcher.newWithBuffer(cBuff);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}

public static String getLocalCityInfo(String ip) {
    String region = null;
    try {
        System.out.println(ip);
        region = dbSearcher.search(ip);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    System.out.println(region);
    if(region!=null){
        String address = region.replace("0|", "");
        char symbol = '|';
        if (address.charAt(address.length() - 1) == symbol) {
            address = address.substring(0, address.length() - 1);
        }
        return address.equals("内网IP|内网IP") ? "内网IP" : address;
    }
    return "";
}

public static void main(String[] args) {
    System.out.println(getLocalCityInfo("1.80.0.0"));

// System.out.println(getLocalCityInfo("101.204.66.178"));
}

`

爆出 arraycopy: source index -15407511 out of bounds for byte[17498059]
以前都没有这样的问题

输入图片说明

评论 (2)

惜阳 创建了任务

xdb文件被破坏了,maven打包过滤对 xdb 的修改,或者其他程序不要修改 xdb 程序。

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(3)
5187 lionsoul 1578914315 5032072 xiyang ycj 1578978831
C
1
https://gitee.com/lionsoul/ip2region.git
git@gitee.com:lionsoul/ip2region.git
lionsoul
ip2region
ip2region

搜索帮助

53164aa7 5694891 3bd8fe86 5694891