Merge pull request #7853 from belugabehr/CopyList

Use ArrayList copy constructor
pull/9092/head
Elliotte Rusty Harold 3 years ago committed by GitHub
commit 21873ae54a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      java/core/src/main/java/com/google/protobuf/FieldSet.java

@ -1081,8 +1081,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
// Wrap the contents in a new list so that the caller cannot change // Wrap the contents in a new list so that the caller cannot change
// the list's contents after setting it. // the list's contents after setting it.
final List newList = new ArrayList(); final List newList = new ArrayList((List) value);
newList.addAll((List) value);
for (final Object element : newList) { for (final Object element : newList) {
verifyType(descriptor, element); verifyType(descriptor, element);
hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder; hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder;

Loading…
Cancel
Save