|
20 | 20 | import com.github.dockerjava.api.command.UpdateContainerCmd; |
21 | 21 | import com.github.dockerjava.core.SSLConfig; |
22 | 22 |
|
| 23 | +import org.apache.http.client.config.RequestConfig; |
23 | 24 | import org.apache.http.config.RegistryBuilder; |
24 | 25 | import org.apache.http.conn.socket.ConnectionSocketFactory; |
25 | 26 | import org.apache.http.conn.socket.PlainConnectionSocketFactory; |
@@ -110,6 +111,8 @@ public class JerseyDockerCmdExecFactory implements DockerCmdExecFactory { |
110 | 111 |
|
111 | 112 | private Integer maxPerRouteConnections = null; |
112 | 113 |
|
| 114 | + private Integer connectionRequestTimeout = null; |
| 115 | + |
113 | 116 | private ClientRequestFilter[] clientRequestFilters = null; |
114 | 117 |
|
115 | 118 | private ClientResponseFilter[] clientResponseFilters = null; |
@@ -216,9 +219,10 @@ public void shutdown() { |
216 | 219 | clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, connManager); |
217 | 220 |
|
218 | 221 | // Configure connection pool timeout |
219 | | - // clientConfig.property(ApacheClientProperties.REQUEST_CONFIG, RequestConfig.custom() |
220 | | - // .setConnectionRequestTimeout(1000).build()); |
221 | | - |
| 222 | + if (connectionRequestTimeout != null) { |
| 223 | + clientConfig.property(ApacheClientProperties.REQUEST_CONFIG, RequestConfig.custom() |
| 224 | + .setConnectionRequestTimeout(connectionRequestTimeout).build()); |
| 225 | + } |
222 | 226 | ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(clientConfig); |
223 | 227 |
|
224 | 228 | if (sslContext != null) { |
@@ -570,6 +574,11 @@ public JerseyDockerCmdExecFactory withMaxPerRouteConnections(Integer maxPerRoute |
570 | 574 | return this; |
571 | 575 | } |
572 | 576 |
|
| 577 | + public JerseyDockerCmdExecFactory withConnectionRequestTimeout(Integer connectionRequestTimeout) { |
| 578 | + this.connectionRequestTimeout = connectionRequestTimeout; |
| 579 | + return this; |
| 580 | + } |
| 581 | + |
573 | 582 | public JerseyDockerCmdExecFactory withClientResponseFilters(ClientResponseFilter... clientResponseFilter) { |
574 | 583 | this.clientResponseFilters = clientResponseFilter; |
575 | 584 | return this; |
|
0 commit comments