From 37f34f0ad66f4f9fa8a2259318c478fd73ed9272 Mon Sep 17 00:00:00 2001 From: David Mollitor Date: Thu, 27 Aug 2020 19:58:37 -0400 Subject: [PATCH] Use ArrayList copy constructor --- java/core/src/main/java/com/google/protobuf/FieldSet.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/FieldSet.java b/java/core/src/main/java/com/google/protobuf/FieldSet.java index d52aede95..8306c471c 100644 --- a/java/core/src/main/java/com/google/protobuf/FieldSet.java +++ b/java/core/src/main/java/com/google/protobuf/FieldSet.java @@ -1078,8 +1078,7 @@ final class FieldSet> { // Wrap the contents in a new list so that the caller cannot change // the list's contents after setting it. - final List newList = new ArrayList(); - newList.addAll((List) value); + final List newList = new ArrayList((List) value); for (final Object element : newList) { verifyType(descriptor.getLiteType(), element); hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder;