Skip to content

Commit

Permalink
feat[enhance]: compatible field of inside protocol class
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Sep 26, 2023
1 parent f54c601 commit f33ab7c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private static String readMethodBody(ProtocolRegistration registration) {
// protocol backwards compatibility,协议向后兼容
if (field.isAnnotationPresent(Compatible.class)) {
var defaultReadObject = enhanceSerializer(fieldRegistration.serializer()).defaultValue(builder, field, fieldRegistration);
builder.append("if (length == -1 || $1.readerIndex() < length + readIndex) {");
builder.append("if (length != -1 && $1.readerIndex() < length + readIndex) {");
var compatibleReadObject = enhanceSerializer(fieldRegistration.serializer()).readObject(builder, field, fieldRegistration);
builder.append(StringUtils.format("{} = {};", defaultReadObject, compatibleReadObject));
builder.append("}");
Expand Down

0 comments on commit f33ab7c

Please sign in to comment.