From 9ab63b8494ae490eeccbffa5cfc1a32bf439fee5 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 25 Jul 2018 19:03:13 +0200 Subject: [PATCH] ListBasedXMLEventReader uses defensive modifiable copy of given List --- .../util/xml/ListBasedXMLEventReader.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/xml/ListBasedXMLEventReader.java b/spring-core/src/main/java/org/springframework/util/xml/ListBasedXMLEventReader.java index 6395ea1e99..ed79471b3d 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/ListBasedXMLEventReader.java +++ b/spring-core/src/main/java/org/springframework/util/xml/ListBasedXMLEventReader.java @@ -16,7 +16,7 @@ package org.springframework.util.xml; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; import javax.xml.stream.events.XMLEvent; @@ -25,7 +25,8 @@ import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** - * Implementation of {@code XMLEventReader} based on a list of {@link XMLEvent XMLEvents}. + * Implementation of {@code XMLEventReader} based on a {@link List} + * of {@link XMLEvent} elements. * * @author Arjen Poutsma * @since 5.0 @@ -38,8 +39,8 @@ class ListBasedXMLEventReader extends AbstractXMLEventReader { public ListBasedXMLEventReader(List events) { - Assert.notNull(events, "'events' must not be null"); - this.events = Collections.unmodifiableList(events); + Assert.notNull(events, "XMLEvent List must not be null"); + this.events = new ArrayList<>(events); }