reta commented on code in PR #2069:
URL: https://github.com/apache/cxf/pull/2069#discussion_r1763739070
##########
rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java:
##########
@@ -243,13 +243,18 @@ private boolean isSslTargetDifferent(URI lastURL, URI
url) {
|| !lastURL.getHost().equals(url.getHost())
|| lastURL.getPort() != url.getPort();
}
-
+
@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)) {
Review Comment:
Think it though, the `os.flush()` my end up with IOException, should be
safer to:
```
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();
}
} finally {
super.close(msg);
msg.remove(HttpClient.class);
}
```
Wdyt?
##########
rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java:
##########
@@ -243,13 +243,18 @@ private boolean isSslTargetDifferent(URI lastURL, URI
url) {
|| !lastURL.getHost().equals(url.getHost())
|| lastURL.getPort() != url.getPort();
}
-
+
@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)) {
Review Comment:
Thinking it though, the `os.flush()` my end up with IOException, should be
safer to:
```
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();
}
} finally {
super.close(msg);
msg.remove(HttpClient.class);
}
```
Wdyt?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]