diff options
author | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:48:38 -0800 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:59:59 -0800 |
commit | 5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 (patch) | |
tree | 0276f81f8848a05d84cd7e287b43d665e30f04e3 /java/core/src/main/java/com/google/protobuf/LazyFieldLite.java | |
parent | e28286fa05d8327fd6c5aa70cfb3be558f0932b8 (diff) | |
download | protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.gz protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.bz2 protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.zip |
Integrated internal changes from Google
Diffstat (limited to 'java/core/src/main/java/com/google/protobuf/LazyFieldLite.java')
-rw-r--r-- | java/core/src/main/java/com/google/protobuf/LazyFieldLite.java | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java index 2febaace..4b0ba0fd 100644 --- a/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java +++ b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java @@ -284,29 +284,8 @@ public class LazyFieldLite { return; } - // At this point we have two fully parsed messages. We can't merge directly from one to the - // other because only generated builder code contains methods to mergeFrom another parsed - // message. We have to serialize one instance and then merge the bytes into the other. This may - // drop extensions from one of the messages if one of the values had an extension set on it - // directly. - // - // To mitigate this we prefer serializing a message that has an extension registry, and - // therefore a chance that all extensions set on it are in that registry. - // - // NOTE: The check for other.extensionRegistry not being null must come first because at this - // point in time if other.extensionRegistry is not null then this.extensionRegistry will not be - // null either. - if (other.extensionRegistry != null) { - setValue(mergeValueAndBytes(this.value, other.toByteString(), other.extensionRegistry)); - return; - } else if (this.extensionRegistry != null) { - setValue(mergeValueAndBytes(other.value, this.toByteString(), this.extensionRegistry)); - return; - } else { - // All extensions from the other message will be dropped because we have no registry. - setValue(mergeValueAndBytes(this.value, other.toByteString(), EMPTY_REGISTRY)); - return; - } + // At this point we have two fully parsed messages. + setValue(this.value.toBuilder().mergeFrom(other.value).build()); } /** |