Skip to content

Commit a78554e

Browse files
committed
Merge branch '6.2.x'
2 parents 0be22a8 + 05814f7 commit a78554e

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

spring-core/src/main/java/org/springframework/core/codec/AbstractCharSequenceDecoder.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,18 @@ private Collection<DataBuffer> processDataBuffer(DataBuffer buffer, DataBufferUt
175175
public final T decode(DataBuffer dataBuffer, ResolvableType elementType,
176176
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
177177

178-
Charset charset = getCharset(mimeType);
179-
T value = decodeInternal(dataBuffer, charset);
180-
DataBufferUtils.release(dataBuffer);
181-
LogFormatUtils.traceDebug(logger, traceOn -> {
182-
String formatted = LogFormatUtils.formatValue(value, !traceOn);
183-
return Hints.getLogPrefix(hints) + "Decoded " + formatted;
184-
});
185-
return value;
178+
try {
179+
Charset charset = getCharset(mimeType);
180+
T value = decodeInternal(dataBuffer, charset);
181+
LogFormatUtils.traceDebug(logger, traceOn -> {
182+
String formatted = LogFormatUtils.formatValue(value, !traceOn);
183+
return Hints.getLogPrefix(hints) + "Decoded " + formatted;
184+
});
185+
return value;
186+
}
187+
finally {
188+
DataBufferUtils.release(dataBuffer);
189+
}
186190
}
187191

188192
private Charset getCharset(@Nullable MimeType mimeType) {

spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferLimitException.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,19 @@
3131
public class DataBufferLimitException extends IllegalStateException {
3232

3333

34+
/**
35+
* Create an instance with the given message.
36+
*/
3437
public DataBufferLimitException(String message) {
3538
super(message);
3639
}
3740

41+
/**
42+
* Create an instance with a message and a cause, e.g. {@link OutOfMemoryError}.
43+
* @since 6.2.12
44+
*/
45+
public DataBufferLimitException(String message, Throwable cause) {
46+
super(message, cause);
47+
}
48+
3849
}

spring-core/src/main/java/org/springframework/core/io/buffer/NettyDataBuffer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,13 @@ public int hashCode() {
379379

380380
@Override
381381
public String toString() {
382-
return this.byteBuf.toString();
382+
try {
383+
return this.byteBuf.toString();
384+
}
385+
catch (OutOfMemoryError ex) {
386+
throw new DataBufferLimitException(
387+
"Failed to convert data buffer to string: " + ex.getMessage(), ex);
388+
}
383389
}
384390

385391

spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ class DefaultWebTestClientBuilder implements WebTestClient.Builder {
6767
static {
6868
ClassLoader loader = DefaultWebTestClientBuilder.class.getClassLoader();
6969
REACTOR_NETTY_CLIENT_PRESENT = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
70-
JETTY_CLIENT_PRESENT = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
70+
JETTY_CLIENT_PRESENT =
71+
ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader) &&
72+
ClassUtils.isPresent("org.eclipse.jetty.reactive.client.ReactiveRequest", loader);
7173
HTTP_COMPONENTS_CLIENT_PRESENT =
7274
ClassUtils.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader) &&
7375
ClassUtils.isPresent("org.apache.hc.core5.reactive.ReactiveDataConsumer", loader);

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
6464
static {
6565
ClassLoader loader = DefaultWebClientBuilder.class.getClassLoader();
6666
REACTOR_NETTY_CLIENT_PRESENT = ClassUtils.isPresent("reactor.netty.http.client.HttpClient", loader);
67-
JETTY_CLIENT_PRESENT = ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader);
67+
JETTY_CLIENT_PRESENT =
68+
ClassUtils.isPresent("org.eclipse.jetty.client.HttpClient", loader) &&
69+
ClassUtils.isPresent("org.eclipse.jetty.reactive.client.ReactiveRequest", loader);
6870
HTTP_COMPONENTS_CLIENT_PRESENT =
6971
ClassUtils.isPresent("org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient", loader) &&
7072
ClassUtils.isPresent("org.apache.hc.core5.reactive.ReactiveDataConsumer", loader);

0 commit comments

Comments
 (0)