diff options
author | Jisi Liu <jisi.liu@gmail.com> | 2017-10-18 12:22:18 -0700 |
---|---|---|
committer | Jisi Liu <jisi.liu@gmail.com> | 2017-10-18 12:22:18 -0700 |
commit | 1a7a7fca804afa1cf67f8be5e71092898ba40334 (patch) | |
tree | 04b3da27c71c607510f34a12cf7856a1b94181ae /java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java | |
parent | c4f59dcc5c13debc572154c8f636b8a9361aacde (diff) | |
download | protobuf-1a7a7fca804afa1cf67f8be5e71092898ba40334.tar.gz protobuf-1a7a7fca804afa1cf67f8be5e71092898ba40334.tar.bz2 protobuf-1a7a7fca804afa1cf67f8be5e71092898ba40334.zip |
Merge from google internal
Diffstat (limited to 'java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java')
-rw-r--r-- | java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java index b192b53e..e017b987 100644 --- a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java +++ b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java @@ -34,7 +34,6 @@ import com.google.protobuf.Descriptors.Descriptor; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.FieldMask; import com.google.protobuf.Message; - import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; @@ -244,6 +243,11 @@ final class FieldMaskTree { + "singluar message field and cannot have sub-fields."); continue; } + if (!source.hasField(field) && !destination.hasField(field)) { + // If the message field is not present in both source and destination, skip recursing + // so we don't create unneccessary empty messages. + continue; + } String childPath = path.isEmpty() ? entry.getKey() : path + "." + entry.getKey(); merge( entry.getValue(), |