From c6e12c6702ca764486f952654ba1568f00efe813 Mon Sep 17 00:00:00 2001 From: Dave Hawkey Date: Thu, 20 Mar 2014 10:55:41 -0600 Subject: Don't reset cachedSize to 0 in getSerializedSize This avoids a race-condition when cachedSize is momentarily set to 0 for non-empty messages if multiple threads call getSerializedSize (e.g. during serialization). Change-Id: I15a8ded92edbf41bf1c8d787960c5bbbc8a323c5 --- src/google/protobuf/compiler/javanano/javanano_message.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/compiler/javanano/javanano_message.cc b/src/google/protobuf/compiler/javanano/javanano_message.cc index 008bec2..3a1b5a5 100644 --- a/src/google/protobuf/compiler/javanano/javanano_message.cc +++ b/src/google/protobuf/compiler/javanano/javanano_message.cc @@ -304,8 +304,8 @@ GenerateMessageSerializationMethods(io::Printer* printer) { printer->Print( "\n" "@Override\n" - "public int getSerializedSize() {\n" - " int size = super.getSerializedSize();\n"); + "protected int computeSerializedSize() {\n" + " int size = super.computeSerializedSize();\n"); printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -314,7 +314,6 @@ GenerateMessageSerializationMethods(io::Printer* printer) { printer->Outdent(); printer->Print( - " cachedSize = size;\n" " return size;\n" "}\n"); } -- cgit v1.1