这里的多个大尺寸在消息模式单一codeInputStream:>协议缓冲无法解析具有消息
message ServerResponse {
optional string ReferenceCode = 1;
optional NestedMessageProto.NestedMessage NestedMessage = 2;//Huge size data in response
optional bool Success = 3 [default = false];
repeated Errors Errors = 4;
}
下面是用于获取从服务响应并调用原应答的方法的代码。
String apiResponse = Server Response
protoResponseClass.parseFrom(apiResponse.getBytes())
its failing when reading the NestedMessage response on below bold line
public int pushLimit(int byteLimit) throws InvalidProtocolBufferException {
if (byteLimit < 0) {
throw InvalidProtocolBufferException.negativeSize();
}
byteLimit += totalBytesRetired + bufferPos;
if (byteLimit > currentLimit) {
currentLimit = byteLimit + currentLimit;
}
final int oldLimit = currentLimit;
**if (byteLimit > oldLimit) {
throw InvalidProtocolBufferException.truncatedMessage();
}**
currentLimit = byteLimit;
recomputeBufferSizeAfterLimit();
return oldLimit;
}
当其读取嵌套消息时,字节限制变得大于旧限制。 什么是解决方案?
由于
请花费更多的精力来设置您的帖子格式。由于缺少缩进和随机空白行,因此您的代码目前很难阅读。 – 2014-09-24 06:14:02