Merge branch '6.0.x'
This commit is contained in:
commit
944305b9f1
|
@ -124,7 +124,7 @@ public final class StringDecoder extends AbstractDataBufferDecoder<String> {
|
||||||
chunks.clear();
|
chunks.clear();
|
||||||
return Mono.just(lastBuffer);
|
return Mono.just(lastBuffer);
|
||||||
}))
|
}))
|
||||||
.doOnTerminate(chunks::releaseAndClear)
|
.doFinally(signalType -> chunks.releaseAndClear())
|
||||||
.doOnDiscard(DataBuffer.class, DataBufferUtils::release)
|
.doOnDiscard(DataBuffer.class, DataBufferUtils::release)
|
||||||
.map(buffer -> decode(buffer, elementType, mimeType, hints));
|
.map(buffer -> decode(buffer, elementType, mimeType, hints));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -18,12 +18,15 @@ package org.springframework.core.codec;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.reactivestreams.Subscription;
|
||||||
|
import reactor.core.publisher.BaseSubscriber;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
|
@ -75,16 +78,17 @@ class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
|
||||||
String s = String.format("%s\n%s\n%s", u, e, o);
|
String s = String.format("%s\n%s\n%s", u, e, o);
|
||||||
Flux<DataBuffer> input = toDataBuffers(s, 1, UTF_8);
|
Flux<DataBuffer> input = toDataBuffers(s, 1, UTF_8);
|
||||||
|
|
||||||
// TODO: temporarily replace testDecodeAll with explicit decode/cancel/empty
|
|
||||||
// see https://github.com/reactor/reactor-core/issues/2041
|
|
||||||
|
|
||||||
// testDecode(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null);
|
|
||||||
// testDecodeCancel(input, TYPE, null, null);
|
|
||||||
// testDecodeEmpty(TYPE, null, null);
|
|
||||||
|
|
||||||
testDecodeAll(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null);
|
testDecodeAll(input, TYPE, step -> step.expectNext(u, e, o).verifyComplete(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // gh-30299
|
||||||
|
public void decodeAndCancelWithPendingChunks() {
|
||||||
|
Flux<DataBuffer> input = toDataBuffers("abc", 1, UTF_8).concatWith(Flux.never());
|
||||||
|
Flux<String> result = this.decoder.decode(input, TYPE, null, null);
|
||||||
|
|
||||||
|
StepVerifier.create(result).thenAwait(Duration.ofMillis(100)).thenCancel().verify();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void decodeMultibyteCharacterUtf16() {
|
void decodeMultibyteCharacterUtf16() {
|
||||||
String u = "ü";
|
String u = "ü";
|
||||||
|
@ -264,4 +268,13 @@ class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class SingleRequestSubscriber extends BaseSubscriber<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void hookOnSubscribe(Subscription subscription) {
|
||||||
|
subscription.request(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue