diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpConnector.java b/spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpConnector.java index c166fce6c3..043849d540 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpConnector.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpConnector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,25 +57,38 @@ public class JettyClientHttpConnector implements ClientHttpConnector { * Constructor with an {@link JettyResourceFactory} that will manage shared resources. * @param resourceFactory the {@link JettyResourceFactory} to use * @param customizer the lambda used to customize the {@link HttpClient} + * @deprecated in favor of {@link JettyClientHttpConnector#JettyClientHttpConnector(HttpClient, JettyResourceFactory)} */ + @Deprecated public JettyClientHttpConnector( JettyResourceFactory resourceFactory, @Nullable Consumer customizer) { - - HttpClient httpClient = new HttpClient(); - httpClient.setExecutor(resourceFactory.getExecutor()); - httpClient.setByteBufferPool(resourceFactory.getByteBufferPool()); - httpClient.setScheduler(resourceFactory.getScheduler()); + this(new HttpClient(), resourceFactory); if (customizer != null) { - customizer.accept(httpClient); + customizer.accept(this.httpClient); } - this.httpClient = httpClient; } /** * Constructor with an initialized {@link HttpClient}. */ public JettyClientHttpConnector(HttpClient httpClient) { + this(httpClient, null); + } + + /** + * Constructor with an initialized {@link HttpClient} and configures it + * with the given {@link JettyResourceFactory}. + * @param httpClient the {@link HttpClient} to use + * @param resourceFactory the {@link JettyResourceFactory} to use + */ + public JettyClientHttpConnector(HttpClient httpClient, + @Nullable JettyResourceFactory resourceFactory) { Assert.notNull(httpClient, "HttpClient is required"); + if (resourceFactory != null) { + httpClient.setExecutor(resourceFactory.getExecutor()); + httpClient.setByteBufferPool(resourceFactory.getByteBufferPool()); + httpClient.setScheduler(resourceFactory.getScheduler()); + } this.httpClient = httpClient; }