aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Hawkey <dhawkey@google.com>2014-03-20 10:55:41 -0600
committerDave Hawkey <dhawkey@google.com>2014-03-21 09:27:23 -0600
commitc6e12c6702ca764486f952654ba1568f00efe813 (patch)
treeb1dcfb28a8cef29d898e45637852816eb490ddc2 /src
parent51ef8f39de376fe71ce5d2c682abe4f974cf8074 (diff)
downloadexternal_protobuf-c6e12c6702ca764486f952654ba1568f00efe813.zip
external_protobuf-c6e12c6702ca764486f952654ba1568f00efe813.tar.gz
external_protobuf-c6e12c6702ca764486f952654ba1568f00efe813.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_message.cc5
1 files changed, 2 insertions, 3 deletions
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");
}