Skip to content

Commit 2d5a97f

Browse files
committed
fix test
1 parent 5d1ee24 commit 2d5a97f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborDecoder.java

+15
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323
import org.jspecify.annotations.Nullable;
2424
import org.reactivestreams.Publisher;
2525
import reactor.core.publisher.Flux;
26+
import reactor.core.publisher.Mono;
27+
import reactor.util.context.ContextView;
2628

2729
import org.springframework.core.ResolvableType;
30+
import org.springframework.core.codec.Hints;
2831
import org.springframework.core.io.buffer.DataBuffer;
32+
import org.springframework.core.io.buffer.DataBufferUtils;
2933
import org.springframework.http.MediaType;
3034
import org.springframework.http.codec.json.AbstractJackson2Decoder;
3135
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
@@ -58,4 +62,15 @@ public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementTy
5862
throw new UnsupportedOperationException("Does not support stream decoding yet");
5963
}
6064

65+
@Override
66+
public Mono<Object> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
67+
return Mono.deferContextual(contextView -> {
68+
69+
Map<String, Object> hintsToUse = contextView.isEmpty() ? hints :
70+
Hints.merge(hints, ContextView.class.getName(), contextView);
71+
72+
return DataBufferUtils.join(input, this.getMaxInMemorySize()).flatMap(dataBuffer ->
73+
Mono.justOrEmpty(decode(dataBuffer, elementType, mimeType, hintsToUse)));
74+
});
75+
}
6176
}

spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType
128128
public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementType,
129129
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
130130

131-
return decodeToFlux(input, elementType, mimeType, hints,null);
131+
return decodeToFlux(input, elementType, mimeType, hints, null);
132132
}
133133

134134
private Flux<Object> decodeToFlux(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints,@Nullable Boolean tokenizeArrays) {

spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java

+3
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ private boolean isTopLevelArrayToken(JsonToken token) {
206206

207207
private void assertInMemorySize(int currentBufferSize, List<TokenBuffer> result) {
208208
if (this.maxInMemorySize >= 0) {
209+
if (currentBufferSize > this.maxInMemorySize) {
210+
raiseLimitException();
211+
}
209212
if (!result.isEmpty()) {
210213
this.byteCount = 0;
211214
}

0 commit comments

Comments
 (0)