|
1 | | -// Copyright 2017, 2020, Oracle and/or its affiliates. |
| 1 | +// Copyright 2017, 2025, Oracle and/or its affiliates. |
2 | 2 | // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. |
3 | 3 |
|
4 | 4 | package com.oracle.wls.exporter; |
|
16 | 16 |
|
17 | 17 | import org.apache.http.Header; |
18 | 18 | import org.apache.http.HttpEntity; |
| 19 | +import org.apache.http.client.config.RequestConfig; |
19 | 20 | import org.apache.http.client.methods.CloseableHttpResponse; |
20 | 21 | import org.apache.http.client.methods.HttpGet; |
21 | 22 | import org.apache.http.client.methods.HttpPost; |
|
45 | 46 | * @author Russell Gold |
46 | 47 | */ |
47 | 48 | public class WebClientImpl extends WebClientCommon { |
| 49 | + // Create default connect, socket, and request timeout. |
| 50 | + // Previously, these timeouts were unlimited. Consider making configurable later, if needed. |
| 51 | + private static final int TIMEOUT = 5000; // 5 seconds |
48 | 52 |
|
49 | 53 | private final List<BasicHeader> addedHeaders = new ArrayList<>(); |
50 | 54 | private final List<BasicHeader> sessionHeaders = new ArrayList<>(); |
@@ -137,11 +141,16 @@ HttpClientExec createClientExec() throws GeneralSecurityException { |
137 | 141 | class ApacheHttpClient implements HttpClientExec { |
138 | 142 | private final CloseableHttpClient client; |
139 | 143 | public ApacheHttpClient() throws GeneralSecurityException { |
140 | | - SelfSignedCertificateAcceptor acceptor = new SelfSignedCertificateAcceptor(); |
| 144 | + RequestConfig config = RequestConfig.custom() |
| 145 | + .setConnectTimeout(TIMEOUT) |
| 146 | + .setSocketTimeout(TIMEOUT) |
| 147 | + .setConnectionRequestTimeout(TIMEOUT) |
| 148 | + .build(); SelfSignedCertificateAcceptor acceptor = new SelfSignedCertificateAcceptor(); |
141 | 149 | client = HttpClientBuilder.create() |
142 | 150 | .setDefaultHeaders(getDefaultHeaders()) |
143 | 151 | .setSSLSocketFactory(acceptor.getSslConnectionSocketFactory()) |
144 | 152 | .setConnectionManager(acceptor.getConnectionManager()) |
| 153 | + .setDefaultRequestConfig(config) |
145 | 154 | .build(); |
146 | 155 | } |
147 | 156 |
|
|
0 commit comments