Don't hold on to full byte array when deserializing protocol buffers.
@@ -53,12 +53,16 @@ public class MessageLiteCodec implements ObjectCodec<MessageLite> {
@Override
public MessageLite deserialize(DeserializationContext unusedContext, CodedInputStream codedIn)
throws IOException, SerializationException {
+ // Don't hold on to full byte array when constructing this proto.
+ codedIn.enableAliasing(false);
try {
MessageLite.Builder builder = builderSupplier.get();
codedIn.readMessage(builder, ExtensionRegistryLite.getEmptyRegistry());
return builder.build();
} catch (InvalidProtocolBufferException e) {
throw new SerializationException("Failed to parse proto of type " + type, e);
+ } finally {
+ codedIn.enableAliasing(true);
}
}
}
