mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Merge branch '6.2.x'
This commit is contained in:
+12
-8
@@ -175,14 +175,18 @@ public abstract class AbstractCharSequenceDecoder<T extends CharSequence> extend
|
||||
public final T decode(DataBuffer dataBuffer, ResolvableType elementType,
|
||||
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
|
||||
|
||||
Charset charset = getCharset(mimeType);
|
||||
T value = decodeInternal(dataBuffer, charset);
|
||||
DataBufferUtils.release(dataBuffer);
|
||||
LogFormatUtils.traceDebug(logger, traceOn -> {
|
||||
String formatted = LogFormatUtils.formatValue(value, !traceOn);
|
||||
return Hints.getLogPrefix(hints) + "Decoded " + formatted;
|
||||
});
|
||||
return value;
|
||||
try {
|
||||
Charset charset = getCharset(mimeType);
|
||||
T value = decodeInternal(dataBuffer, charset);
|
||||
LogFormatUtils.traceDebug(logger, traceOn -> {
|
||||
String formatted = LogFormatUtils.formatValue(value, !traceOn);
|
||||
return Hints.getLogPrefix(hints) + "Decoded " + formatted;
|
||||
});
|
||||
return value;
|
||||
}
|
||||
finally {
|
||||
DataBufferUtils.release(dataBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
private Charset getCharset(@Nullable MimeType mimeType) {
|
||||
|
||||
+11
@@ -31,8 +31,19 @@ package org.springframework.core.io.buffer;
|
||||
public class DataBufferLimitException extends IllegalStateException {
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance with the given message.
|
||||
*/
|
||||
public DataBufferLimitException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance with a message and a cause, e.g. {@link OutOfMemoryError}.
|
||||
* @since 6.2.12
|
||||
*/
|
||||
public DataBufferLimitException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -379,7 +379,13 @@ public class NettyDataBuffer implements PooledDataBuffer {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.byteBuf.toString();
|
||||
try {
|
||||
return this.byteBuf.toString();
|
||||
}
|
||||
catch (OutOfMemoryError ex) {
|
||||
throw new DataBufferLimitException(
|
||||
"Failed to convert data buffer to string: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -67,7 +67,9 @@ class DefaultWebTestClientBuilder implements WebTestClient.Builder {
|
||||
static {
|
||||
ClassLoader loader = DefaultWebTestClientBuilder.class.getClassLoader();
|
||||
REACTOR_NETTY_CLIENT_PRESENT = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
JETTY_CLIENT_PRESENT = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
|
||||
JETTY_CLIENT_PRESENT =
|
||||
ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader) &&
|
||||
ClassUtils.isPresent("org.eclipse.jetty.reactive.client.ReactiveRequest", loader);
|
||||
HTTP_COMPONENTS_CLIENT_PRESENT =
|
||||
ClassUtils.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader) &&
|
||||
ClassUtils.isPresent("org.apache.hc.core5.reactive.ReactiveDataConsumer", loader);
|
||||
|
||||
+3
-1
@@ -64,7 +64,9 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
||||
static {
|
||||
ClassLoader loader = DefaultWebClientBuilder.class.getClassLoader();
|
||||
REACTOR_NETTY_CLIENT_PRESENT = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
|
||||
JETTY_CLIENT_PRESENT = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
|
||||
JETTY_CLIENT_PRESENT =
|
||||
ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader) &&
|
||||
ClassUtils.isPresent("org.eclipse.jetty.reactive.client.ReactiveRequest", loader);
|
||||
HTTP_COMPONENTS_CLIENT_PRESENT =
|
||||
ClassUtils.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader) &&
|
||||
ClassUtils.isPresent("org.apache.hc.core5.reactive.ReactiveDataConsumer", loader);
|
||||
|
||||
Reference in New Issue
Block a user