diff --git a/pom.xml b/pom.xml index d24f9f4..a4d74bd 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 io.github.yezhihao protostar - 2.0.6.RELEASE + 2.0.7.RELEASE jar Protostar @@ -33,10 +33,10 @@ 1.8 @ - UTF-8 - UTF-8 ${java.version} ${java.version} + UTF-8 + UTF-8 true @@ -62,7 +62,7 @@ io.netty netty-buffer - 4.1.68.Final + 4.1.69.Final provided diff --git a/src/main/java/io/github/yezhihao/protostar/converter/MapConverter.java b/src/main/java/io/github/yezhihao/protostar/converter/MapConverter.java index 59bb9e4..01cfe43 100644 --- a/src/main/java/io/github/yezhihao/protostar/converter/MapConverter.java +++ b/src/main/java/io/github/yezhihao/protostar/converter/MapConverter.java @@ -25,19 +25,27 @@ public abstract class MapConverter extends PrepareLoadStrategy implements if (!input.isReadable()) return null; Map 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; }