hiwepy / ip2region-spring-boot-starter

spring-boot-starter-ip2region
Apache License 2.0
45 stars 20 forks source link

使用外部文件readFully会导致EOFException异常 #1

Open lilaizhencn opened 5 years ago

lilaizhencn commented 5 years ago

异常:

Caused by: java.io.EOFException
    at java.base/java.io.RandomAccessFile.readFully(Unknown Source)
    at org.nutz.plugins.ip2region.impl.RandomAccessFileDBReader.readFully(RandomAccessFileDBReader.java:24)
    at org.nutz.plugins.ip2region.DbSearcher.binarySearch(DbSearcher.java:336)
    at org.nutz.plugins.ip2region.DbSearcher.binarySearch(DbSearcher.java:391)
    at com.polarisex.ip2region.IP2regionTemplate.binarySearch(IP2regionTemplate.java:142)
    at com.polarisex.ip2region.Application.test(Application.java:35)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
    ... 17 more

文件是从github下载的最新的1.9的ip库, 配置:

ip2region:
  external: true
  index-block-size: 4096
  total-header-size: 8192
  location: classpath:ip2region/ip2region.db
lilaizhencn commented 5 years ago

实际是下标越界,读到的索引超过了最大索引。

hiwepy commented 5 years ago

嗯 我抽时间查下,最近比较忙