You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2023/09/27 02:05:04 UTC
[cxf] branch main updated: [CXF-8935]:Add doPrivileged block to httpclient.sendAsync() in HttpClientHTTPConduit
This is an automated email from the ASF dual-hosted git repository.
ema pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new 7e68c884c6 [CXF-8935]:Add doPrivileged block to httpclient.sendAsync() in HttpClientHTTPConduit
7e68c884c6 is described below
commit 7e68c884c61f30199b7925c2f9d4020c3a5d6f1d
Author: Jim Ma <em...@apache.org>
AuthorDate: Tue Sep 26 11:17:14 2023 +0800
[CXF-8935]:Add doPrivileged block to httpclient.sendAsync() in HttpClientHTTPConduit
---
.../cxf/transport/http/HttpClientHTTPConduit.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 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 d99309b3ca..86284ba093 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
@@ -548,8 +548,21 @@ public class HttpClientHTTPConduit extends URLConnectionHTTPConduit {
final BodyHandler<InputStream> handler = BodyHandlers.ofInputStream();
-
- future = cl.sendAsync(request, handler);
+ if (System.getSecurityManager() != null) {
+ try {
+ future = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<CompletableFuture<HttpResponse<InputStream>>>() {
+ @Override
+ public CompletableFuture<HttpResponse<InputStream>> run() throws IOException {
+ return cl.sendAsync(request, handler);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ future = cl.sendAsync(request, handler);
+ }
future.exceptionally(ex -> {
if (pout != null) {
synchronized (pout) {