Correct since declarations in Netty 4 client support
This commit is contained in:
parent
015afef52b
commit
a6e7044523
|
|
@ -48,7 +48,7 @@ import org.springframework.util.concurrent.SettableListenableFuture;
|
|||
* <p>Created via the {@link Netty4ClientHttpRequestFactory}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.2
|
||||
* @since 4.1.2
|
||||
*/
|
||||
class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements ClientHttpRequest {
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements
|
|||
private final ByteBufOutputStream body;
|
||||
|
||||
|
||||
Netty4ClientHttpRequest(Bootstrap bootstrap, URI uri, HttpMethod method, int maxRequestSize) {
|
||||
public Netty4ClientHttpRequest(Bootstrap bootstrap, URI uri, HttpMethod method, int maxRequestSize) {
|
||||
this.bootstrap = bootstrap;
|
||||
this.uri = uri;
|
||||
this.method = method;
|
||||
|
|
@ -81,7 +81,7 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements
|
|||
|
||||
@Override
|
||||
protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException {
|
||||
return body;
|
||||
return this.body;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import org.springframework.util.Assert;
|
|||
* across multiple clients.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.2
|
||||
* @since 4.1.2
|
||||
*/
|
||||
public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
|
||||
AsyncClientHttpRequestFactory, InitializingBean, DisposableBean {
|
||||
|
|
@ -59,11 +59,11 @@ public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
|
|||
|
||||
private final boolean defaultEventLoopGroup;
|
||||
|
||||
private SslContext sslContext;
|
||||
|
||||
private int maxRequestSize = DEFAULT_MAX_REQUEST_SIZE;
|
||||
|
||||
private Bootstrap bootstrap;
|
||||
private SslContext sslContext;
|
||||
|
||||
private volatile Bootstrap bootstrap;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -79,13 +79,12 @@ public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
|
|||
/**
|
||||
* Create a new {@code Netty4ClientHttpRequestFactory} with the given
|
||||
* {@link EventLoopGroup}.
|
||||
*
|
||||
* <p><b>NOTE:</b> the given group will <strong>not</strong> be
|
||||
* {@linkplain EventLoopGroup#shutdownGracefully() shutdown} by this factory; doing
|
||||
* so becomes the responsibility of the caller.
|
||||
* {@linkplain EventLoopGroup#shutdownGracefully() shutdown} by this factory;
|
||||
* doing so becomes the responsibility of the caller.
|
||||
*/
|
||||
public Netty4ClientHttpRequestFactory(EventLoopGroup eventLoopGroup) {
|
||||
Assert.notNull(eventLoopGroup, "'eventLoopGroup' must not be null");
|
||||
Assert.notNull(eventLoopGroup, "EventLoopGroup must not be null");
|
||||
this.eventLoopGroup = eventLoopGroup;
|
||||
this.defaultEventLoopGroup = false;
|
||||
}
|
||||
|
|
@ -117,7 +116,6 @@ public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
|
|||
@Override
|
||||
protected void initChannel(SocketChannel channel) throws Exception {
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
|
||||
if (sslContext != null) {
|
||||
pipeline.addLast(sslContext.newHandler(channel.alloc()));
|
||||
}
|
||||
|
|
@ -131,10 +129,11 @@ public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
getBootstrap();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
|
||||
return createRequestInternal(uri, httpMethod);
|
||||
|
|
@ -149,10 +148,11 @@ public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory,
|
|||
return new Netty4ClientHttpRequest(getBootstrap(), uri, httpMethod, this.maxRequestSize);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() throws InterruptedException {
|
||||
if (this.defaultEventLoopGroup) {
|
||||
// clean up the EventLoopGroup if we created it in the constructor
|
||||
// Clean up the EventLoopGroup if we created it in the constructor
|
||||
this.eventLoopGroup.shutdownGracefully().sync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.springframework.util.Assert;
|
|||
* Netty 4 to execute requests.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.2
|
||||
* @since 4.1.2
|
||||
*/
|
||||
class Netty4ClientHttpResponse extends AbstractClientHttpResponse {
|
||||
|
||||
|
|
@ -42,12 +42,12 @@ class Netty4ClientHttpResponse extends AbstractClientHttpResponse {
|
|||
|
||||
private final ByteBufInputStream body;
|
||||
|
||||
private HttpHeaders headers;
|
||||
private volatile HttpHeaders headers;
|
||||
|
||||
|
||||
Netty4ClientHttpResponse(ChannelHandlerContext context, FullHttpResponse nettyResponse) {
|
||||
Assert.notNull(context, "'context' must not be null");
|
||||
Assert.notNull(nettyResponse, "'nettyResponse' must not be null");
|
||||
public Netty4ClientHttpResponse(ChannelHandlerContext context, FullHttpResponse nettyResponse) {
|
||||
Assert.notNull(context, "ChannelHandlerContext must not be null");
|
||||
Assert.notNull(nettyResponse, "FullHttpResponse must not be null");
|
||||
this.context = context;
|
||||
this.nettyResponse = nettyResponse;
|
||||
this.body = new ByteBufInputStream(this.nettyResponse.content());
|
||||
|
|
@ -87,4 +87,5 @@ class Netty4ClientHttpResponse extends AbstractClientHttpResponse {
|
|||
this.nettyResponse.release();
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue