You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2021/02/22 10:34:23 UTC

[GitHub] [cxf] amarkevich commented on a change in pull request #748: CXF-8422: Unclosed input streams after using org.apache.cxf.tools.wsdlto.WSDLToJava (targeting StAX's XMLStreamReader)

amarkevich commented on a change in pull request #748:
URL: https://github.com/apache/cxf/pull/748#discussion_r580143043



##########
File path: core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
##########
@@ -1660,22 +1667,38 @@ public static XMLStreamReader createXMLStreamReader(InputSource src) {
         String sysId = src.getSystemId() == null ? null : src.getSystemId();
         String pubId = src.getPublicId() == null ? null : src.getPublicId();
         if (src.getByteStream() != null) {
+            final InputStream is = src.getByteStream();
+
             if (src.getEncoding() == null) {
-                StreamSource ss = new StreamSource(src.getByteStream(), sysId);
+                final StreamSource ss = new StreamSource(is, sysId);
                 ss.setPublicId(pubId);
-                return createXMLStreamReader(ss);
+                
+                final XMLStreamReader xmlStreamReader = createXMLStreamReader(ss);
+                if (AUTO_CLOSE_INPUT_SOURCE) {
+                    return new AutoCloseableXMLStreamReader(xmlStreamReader, is);

Review comment:
       AutoCloseable wont close source stream because returning XMLStreamReader cant be defined inside try-with-resources block




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org