Add classpath detection for Reactor Netty 2

See gh-28847
This commit is contained in:
rstoyanchev
2022-09-12 09:36:18 +01:00
parent fa1f7f6dc7
commit 2f4c39ba2a
6 changed files with 35 additions and 32 deletions

View File

@@ -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();
}

View File

@@ -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() +

View File

@@ -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();