diff options
author | Dave Hawkey <dhawkey@google.com> | 2014-03-20 10:55:41 -0600 |
---|---|---|
committer | Dave Hawkey <dhawkey@google.com> | 2014-04-10 08:21:44 -0600 |
commit | c82101204dcde798f870d95e91f5483c3e57eb29 (patch) | |
tree | 377a25f535ffb0e37a1762f2d3b7b1ca83a4ece1 /java/README.txt | |
parent | ce2f59915e0b41c935e3f72a2b7b71b6c19b6860 (diff) | |
download | external_protobuf-c82101204dcde798f870d95e91f5483c3e57eb29.zip external_protobuf-c82101204dcde798f870d95e91f5483c3e57eb29.tar.gz external_protobuf-c82101204dcde798f870d95e91f5483c3e57eb29.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).
This is a retry of https://android-review.googlesource.com/#/c/88570/.
getSerializedSize() has been kept non-final so that messages generated
with a previous version of the compiler will not break.
Change-Id: I8d8154a10938cde579ae19c55eae55b1e70e0bda
Diffstat (limited to 'java/README.txt')
-rw-r--r-- | java/README.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/java/README.txt b/java/README.txt index 13865f6..f958d14 100644 --- a/java/README.txt +++ b/java/README.txt @@ -437,6 +437,15 @@ and the runtime overhead. An overview of Nano features: MessageNano. - The 'bytes' type translates to the Java type byte[]. +The generated messages are not thread-safe for writes, but may be +used simultaneously from multiple threads in a read-only manner. +In other words, an appropriate synchronization mechanism (such as +a ReadWriteLock) must be used to ensure that a message, its +ancestors, and descendants are not accessed by any other threads +while the message is being modified. Field reads, getter methods, +toByteArray(...), writeTo(...), getCachedSize(), and +getSerializedSize() are all considered read-only operations. + IMPORTANT: If you have fields with defaults and opt out of accessors How fields with defaults are serialized has changed. Because we don't |