This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 5e99df45a0ca001c9606b86cf340c75760f3a220
Author: Daniel Kulp <d...@kulp.com>
AuthorDate: Tue Sep 5 08:44:50 2023 -0400

    TransportURIResolver replaces the InputStream, but doesn't close the 
original.
    
    (cherry picked from commit 86cb53f39b3f14fee17a601a70cfcf04a2bbc40f)
---
 .../java/org/apache/cxf/transport/TransportURIResolver.java  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git 
a/core/src/main/java/org/apache/cxf/transport/TransportURIResolver.java 
b/core/src/main/java/org/apache/cxf/transport/TransportURIResolver.java
index 4c1446ef04..752b1f0f8c 100644
--- a/core/src/main/java/org/apache/cxf/transport/TransportURIResolver.java
+++ b/core/src/main/java/org/apache/cxf/transport/TransportURIResolver.java
@@ -112,7 +112,7 @@ public class TransportURIResolver extends 
ExtendedURIResolver {
                     // set the endpointInfo name which could be used for 
configuration
                     info.setName(new QName("http://cxf.apache.org";, 
"TransportURIResolver"));
                     info.setAddress(base.toString());
-                    final Conduit c = ci.getConduit(info, bus);
+                    Conduit c = ci.getConduit(info, bus);
                     Message message = new MessageImpl();
                     Exchange exch = new ExchangeImpl();
                     exch.put(Bus.class, bus);
@@ -123,9 +123,8 @@ public class TransportURIResolver extends 
ExtendedURIResolver {
                         public void onMessage(Message message) {
                             LoadingByteArrayOutputStream bout = new 
LoadingByteArrayOutputStream();
                             try {
-                                
IOUtils.copy(message.getContent(InputStream.class), bout);
+                                
IOUtils.copyAndCloseInput(message.getContent(InputStream.class), bout);
                                 message.getExchange().put(InputStream.class, 
bout.createInputStream());
-                                c.close(message);
                             } catch (IOException e) {
                                 //ignore
                             }
@@ -133,6 +132,12 @@ public class TransportURIResolver extends 
ExtendedURIResolver {
                     });
                     c.prepare(message);
                     c.close(message);
+                    if (exch.getInMessage() != null) {
+                        c.close(exch.getInMessage());
+                    }
+                    if (exch.getInFaultMessage() != null) {
+                        c.close(exch.getInFaultMessage());
+                    }
                     c.close();
                     InputStream ins = exch.get(InputStream.class);
                     resourceOpened.add(ins);
@@ -150,6 +155,7 @@ public class TransportURIResolver extends 
ExtendedURIResolver {
             } catch (Exception e) {
                 //ignore
                 LOG.log(Level.FINEST, "Conduit initiator could not resolve " + 
baseUri + " " + curUri, e);
+                e.printStackTrace();
             }
         }
         if (is == null

Reply via email to