Skip to content

Commit

Permalink
Merge pull request #7853 from belugabehr/CopyList
Browse files Browse the repository at this point in the history
Use ArrayList copy constructor
  • Loading branch information
elharo committed Oct 13, 2021
2 parents 39013ab + 37f34f0 commit 21873ae
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions java/core/src/main/java/com/google/protobuf/FieldSet.java
Expand Up @@ -1081,8 +1081,7 @@ public void setField(final T descriptor, Object value) {

// 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, element);
hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder;
Expand Down

0 comments on commit 21873ae

Please sign in to comment.