Skip to content

Commit c89fb74

Browse files
committed
ListBasedXMLEventReader uses defensive modifiable copy of given List
(cherry picked from commit 9ab63b8)
1 parent e214ee5 commit c89fb74

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

spring-core/src/main/java/org/springframework/util/xml/ListBasedXMLEventReader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.util.xml;
1818

19-
import java.util.Collections;
19+
import java.util.ArrayList;
2020
import java.util.List;
2121
import java.util.NoSuchElementException;
2222
import javax.xml.stream.events.XMLEvent;
@@ -25,7 +25,8 @@
2525
import org.springframework.util.Assert;
2626

2727
/**
28-
* Implementation of {@code XMLEventReader} based on a list of {@link XMLEvent}s.
28+
* Implementation of {@code XMLEventReader} based on a {@link List}
29+
* of {@link XMLEvent} elements.
2930
*
3031
* @author Arjen Poutsma
3132
* @since 5.0
@@ -38,8 +39,8 @@ class ListBasedXMLEventReader extends AbstractXMLEventReader {
3839

3940

4041
public ListBasedXMLEventReader(List<XMLEvent> events) {
41-
Assert.notNull(events, "'events' must not be null");
42-
this.events = Collections.unmodifiableList(events);
42+
Assert.notNull(events, "XMLEvent List must not be null");
43+
this.events = new ArrayList<>(events);
4344
}
4445

4546

0 commit comments

Comments
 (0)