deployed 2.0.7.RELEASE,增加MapConverter鲁棒性,并记录错误信息
parent
a802097a21
commit
aad9821481
8
pom.xml
8
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.yezhihao</groupId>
|
||||
<artifactId>protostar</artifactId>
|
||||
<version>2.0.6.RELEASE</version>
|
||||
<version>2.0.7.RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Protostar</name>
|
||||
|
@ -33,10 +33,10 @@
|
|||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<resource.delimiter>@</resource.delimiter>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
|||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-buffer</artifactId>
|
||||
<version>4.1.68.Final</version>
|
||||
<version>4.1.69.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -25,19 +25,27 @@ public abstract class MapConverter<K, V> extends PrepareLoadStrategy implements
|
|||
if (!input.isReadable())
|
||||
return null;
|
||||
Map<K, V> map = new TreeMap<>();
|
||||
do {
|
||||
K key = readKey(input);
|
||||
int length = ByteBufUtils.readInt(input, valueSize());
|
||||
K key = null;
|
||||
int length = 0;
|
||||
try {
|
||||
do {
|
||||
key = readKey(input);
|
||||
length = ByteBufUtils.readInt(input, valueSize());
|
||||
if (length <= 0)
|
||||
continue;
|
||||
|
||||
if (input.isReadable(length)) {
|
||||
int writerIndex = input.writerIndex();
|
||||
input.writerIndex(input.readerIndex() + length);
|
||||
map.put(key, (V) readValue(key, input));
|
||||
input.writerIndex(writerIndex);
|
||||
} else {
|
||||
map.put(key, (V) readValue(key, input));
|
||||
}
|
||||
} while (input.isReadable());
|
||||
if (input.isReadable(length)) {
|
||||
int writerIndex = input.writerIndex();
|
||||
input.writerIndex(input.readerIndex() + length);
|
||||
map.put(key, (V) readValue(key, input));
|
||||
input.writerIndex(writerIndex);
|
||||
} else {
|
||||
map.put(key, (V) readValue(key, input));
|
||||
}
|
||||
} while (input.isReadable());
|
||||
} catch (Exception e) {
|
||||
log.warn("解析出错:KEY[{}], LENGTH[{}]", key, length);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue