Skip to content

Commit ab1b8de

Browse files
committed
Ensure XmlEventDecoder compiles on JDK 9 and 11
1 parent 55b764b commit ab1b8de

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-web/src/main/java/org/springframework/http/codec/xml/XmlEventDecoder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.InputStream;
2020
import java.util.ArrayList;
21+
import java.util.Iterator;
2122
import java.util.List;
2223
import java.util.Map;
2324
import java.util.function.Function;
@@ -76,6 +77,7 @@
7677
* by other decoders which are registered by default.
7778
*
7879
* @author Arjen Poutsma
80+
* @author Sam Brannen
7981
* @since 5.0
8082
*/
8183
public class XmlEventDecoder extends AbstractDecoder<XMLEvent> {
@@ -94,7 +96,7 @@ public XmlEventDecoder() {
9496

9597

9698
@Override
97-
@SuppressWarnings({"rawtypes", "unchecked"}) // on JDK 9 where XMLEventReader is Iterator<Object>
99+
@SuppressWarnings({"rawtypes", "unchecked", "cast"}) // on JDK 9 where XMLEventReader is Iterator<Object> instead of simply Iterator
98100
public Flux<XMLEvent> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
99101
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
100102

@@ -110,7 +112,9 @@ public Flux<XMLEvent> decode(Publisher<DataBuffer> inputStream, ResolvableType e
110112
InputStream is = dataBuffer.asInputStream();
111113
return () -> {
112114
try {
113-
return inputFactory.createXMLEventReader(is);
115+
// Explicit cast to (Iterator) is necessary on JDK 9+ since XMLEventReader
116+
// now extends Iterator<Object> instead of simply Iterator
117+
return (Iterator) inputFactory.createXMLEventReader(is);
114118
}
115119
catch (XMLStreamException ex) {
116120
throw Exceptions.propagate(ex);

0 commit comments

Comments
 (0)