From 3355144e1d5ab3182df241d86017d845a0c845c9 Mon Sep 17 00:00:00 2001 From: jgoodyear Date: Tue, 17 Sep 2024 20:06:34 -0230 Subject: [PATCH] [CXF-9059] Update impl to handle flush IOException --- .../cxf/transport/http/HttpClientHTTPConduit.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java index 6b14da7fb3a..d40582d576e 100644 --- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java +++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java @@ -246,10 +246,14 @@ private boolean isSslTargetDifferent(URI lastURL, URI url) { @Override public void close(Message msg) throws IOException { - OutputStream os = msg.getContent(OutputStream.class); - // Java 21 may hang on close, we flush stream to help close them out. - if (os != null && AutoCloseable.class.isAssignableFrom(HttpClient.class)) { - os.flush(); + try { + OutputStream os = msg.getContent(OutputStream.class); + // Java 21 may hang on close, we flush stream to help close them out. + if (os != null && AutoCloseable.class.isAssignableFrom(HttpClient.class)) { + os.flush(); + } + } catch (IOException ioException) { + // ignore } super.close(msg); msg.remove(HttpClient.class);