parent
fa1f7f6dc7
commit
2f4c39ba2a
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
|
@ -28,6 +28,7 @@ import org.springframework.http.client.reactive.ClientHttpConnector;
|
|||
import org.springframework.http.client.reactive.HttpComponentsClientHttpConnector;
|
||||
import org.springframework.http.client.reactive.JettyClientHttpConnector;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.http.client.reactive.ReactorNetty2ClientHttpConnector;
|
||||
import org.springframework.http.codec.ClientCodecConfigurer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -51,7 +52,9 @@ import org.springframework.web.util.UriBuilderFactory;
|
|||
*/
|
||||
class DefaultWebTestClientBuilder implements WebTestClient.Builder {
|
||||
|
||||
private static final boolean reactorClientPresent;
|
||||
private static final boolean reactorNettyClientPresent;
|
||||
|
||||
private static final boolean reactorNetty2ClientPresent;
|
||||
|
||||
private static final boolean jettyClientPresent;
|
||||
|
||||
|
|
@ -61,7 +64,8 @@ class DefaultWebTestClientBuilder implements WebTestClient.Builder {
|
|||
|
||||
static {
|
||||
ClassLoader loader = DefaultWebTestClientBuilder.class.getClassLoader();
|
||||
reactorClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
reactorNettyClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
reactorNetty2ClientPresent = ClassUtils.isPresent("reactor.netty5.http.client.HttpClient", loader);
|
||||
jettyClientPresent = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
|
||||
httpComponentsClientPresent =
|
||||
ClassUtils.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader) &&
|
||||
|
|
@ -301,9 +305,12 @@ class DefaultWebTestClientBuilder implements WebTestClient.Builder {
|
|||
}
|
||||
|
||||
private static ClientHttpConnector initConnector() {
|
||||
if (reactorClientPresent) {
|
||||
if (reactorNettyClientPresent) {
|
||||
return new ReactorClientHttpConnector();
|
||||
}
|
||||
else if (reactorNetty2ClientPresent) {
|
||||
return new ReactorNetty2ClientHttpConnector();
|
||||
}
|
||||
else if (jettyClientPresent) {
|
||||
return new JettyClientHttpConnector();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import org.springframework.http.HttpMethod;
|
|||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
|
@ -54,11 +53,6 @@ import org.springframework.util.ObjectUtils;
|
|||
*/
|
||||
class ReactorNetty2ClientHttpResponse implements ClientHttpResponse {
|
||||
|
||||
/** Reactor Netty 1.0.5+. */
|
||||
static final boolean reactorNettyRequestChannelOperationsIdPresent = ClassUtils.isPresent(
|
||||
"reactor.netty5.ChannelOperationsId", ReactorNetty2ClientHttpResponse.class.getClassLoader());
|
||||
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ReactorNetty2ClientHttpResponse.class);
|
||||
|
||||
private final HttpClientResponse response;
|
||||
|
|
@ -102,10 +96,7 @@ class ReactorNetty2ClientHttpResponse implements ClientHttpResponse {
|
|||
|
||||
@Override
|
||||
public String getId() {
|
||||
String id = null;
|
||||
if (reactorNettyRequestChannelOperationsIdPresent) {
|
||||
id = ChannelOperationsIdHelper.getId(this.response);
|
||||
}
|
||||
String id = ChannelOperationsIdHelper.getId(this.response);
|
||||
if (id == null && this.response instanceof Connection connection) {
|
||||
id = connection.channel().id().asShortText();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import org.springframework.http.HttpLogging;
|
|||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
|
|
@ -53,10 +52,6 @@ import org.springframework.util.MultiValueMap;
|
|||
*/
|
||||
class ReactorNetty2ServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
/** Reactor Netty 1.0.5+. */
|
||||
static final boolean reactorNettyRequestChannelOperationsIdPresent = ClassUtils.isPresent(
|
||||
"reactor.netty.ChannelOperationsId", ReactorNetty2ServerHttpRequest.class.getClassLoader());
|
||||
|
||||
private static final Log logger = HttpLogging.forLogName(ReactorNetty2ServerHttpRequest.class);
|
||||
|
||||
|
||||
|
|
@ -213,11 +208,9 @@ class ReactorNetty2ServerHttpRequest extends AbstractServerHttpRequest {
|
|||
|
||||
@Override
|
||||
protected String initLogPrefix() {
|
||||
if (reactorNettyRequestChannelOperationsIdPresent) {
|
||||
String id = (ChannelOperationsIdHelper.getId(this.request));
|
||||
if (id != null) {
|
||||
return id;
|
||||
}
|
||||
String id = (ChannelOperationsIdHelper.getId(this.request));
|
||||
if (id != null) {
|
||||
return id;
|
||||
}
|
||||
if (this.request instanceof Connection) {
|
||||
return ((Connection) this.request).channel().id().asShortText() +
|
||||
|
|
|
|||
|
|
@ -128,10 +128,8 @@ class ReactorNetty2ServerHttpResponse extends AbstractServerHttpResponse impleme
|
|||
@Override
|
||||
protected void touchDataBuffer(DataBuffer buffer) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (ReactorNetty2ServerHttpRequest.reactorNettyRequestChannelOperationsIdPresent) {
|
||||
if (ChannelOperationsIdHelper.touch(buffer, this.response)) {
|
||||
return;
|
||||
}
|
||||
if (ChannelOperationsIdHelper.touch(buffer, this.response)) {
|
||||
return;
|
||||
}
|
||||
this.response.withConnection(connection -> {
|
||||
ChannelId id = connection.channel().id();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.springframework.http.client.reactive.HttpComponentsClientHttpConnecto
|
|||
import org.springframework.http.client.reactive.JdkClientHttpConnector;
|
||||
import org.springframework.http.client.reactive.JettyClientHttpConnector;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.http.client.reactive.ReactorNetty2ClientHttpConnector;
|
||||
import org.springframework.http.codec.ClientCodecConfigurer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -53,7 +54,9 @@ import org.springframework.web.util.UriBuilderFactory;
|
|||
*/
|
||||
final class DefaultWebClientBuilder implements WebClient.Builder {
|
||||
|
||||
private static final boolean reactorClientPresent;
|
||||
private static final boolean reactorNettyClientPresent;
|
||||
|
||||
private static final boolean reactorNetty2ClientPresent;
|
||||
|
||||
private static final boolean jettyClientPresent;
|
||||
|
||||
|
|
@ -61,7 +64,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
|
||||
static {
|
||||
ClassLoader loader = DefaultWebClientBuilder.class.getClassLoader();
|
||||
reactorClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
reactorNettyClientPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
reactorNetty2ClientPresent = ClassUtils.isPresent("reactor.netty5.http.client.HttpClient", loader);
|
||||
jettyClientPresent = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
|
||||
httpComponentsClientPresent =
|
||||
ClassUtils.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader) &&
|
||||
|
|
@ -306,9 +310,12 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
}
|
||||
|
||||
private ClientHttpConnector initConnector() {
|
||||
if (reactorClientPresent) {
|
||||
if (reactorNettyClientPresent) {
|
||||
return new ReactorClientHttpConnector();
|
||||
}
|
||||
else if (reactorNetty2ClientPresent) {
|
||||
return new ReactorNetty2ClientHttpConnector();
|
||||
}
|
||||
else if (jettyClientPresent) {
|
||||
return new JettyClientHttpConnector();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
|
@ -74,12 +74,15 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
|
|||
|
||||
private static final boolean reactorNettyPresent;
|
||||
|
||||
private static final boolean reactorNetty2Present;
|
||||
|
||||
static {
|
||||
ClassLoader loader = HandshakeWebSocketService.class.getClassLoader();
|
||||
tomcatPresent = ClassUtils.isPresent("org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", loader);
|
||||
jettyPresent = ClassUtils.isPresent("org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer", loader);
|
||||
undertowPresent = ClassUtils.isPresent("io.undertow.websockets.WebSocketProtocolHandshakeHandler", loader);
|
||||
reactorNettyPresent = ClassUtils.isPresent("reactor.netty.http.server.HttpServerResponse", loader);
|
||||
reactorNetty2Present = ClassUtils.isPresent("reactor.netty5.http.server.HttpServerResponse", loader);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -126,6 +129,10 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
|
|||
// As late as possible (Reactor Netty commonly used for WebClient)
|
||||
className = "ReactorNettyRequestUpgradeStrategy";
|
||||
}
|
||||
else if (reactorNetty2Present) {
|
||||
// As late as possible (Reactor Netty commonly used for WebClient)
|
||||
className = "ReactorNetty2RequestUpgradeStrategy";
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("No suitable default RequestUpgradeStrategy found");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue