|
18 | 18 |
|
19 | 19 | import java.io.File;
|
20 | 20 | import java.io.IOException;
|
| 21 | +import java.nio.channels.ReadableByteChannel; |
21 | 22 | import java.time.Duration;
|
22 | 23 | import java.util.Map;
|
23 | 24 | import java.util.function.Consumer;
|
|
44 | 45 | import org.springframework.util.MultiValueMap;
|
45 | 46 |
|
46 | 47 | import static java.util.Collections.emptyMap;
|
| 48 | +import static java.util.Collections.singletonMap; |
47 | 49 | import static org.hamcrest.core.StringStartsWith.startsWith;
|
48 | 50 | import static org.junit.Assert.assertEquals;
|
49 | 51 | import static org.junit.Assert.assertFalse;
|
@@ -149,6 +151,24 @@ public void readPartsWithoutDemand() {
|
149 | 151 | subscriber.cancel();
|
150 | 152 | }
|
151 | 153 |
|
| 154 | + @Test |
| 155 | + public void gh23768() throws IOException { |
| 156 | + ReadableByteChannel channel = new ClassPathResource("invalid.multipart", getClass()).readableChannel(); |
| 157 | + Flux<DataBuffer> body = DataBufferUtils.readByteChannel(() -> channel, this.bufferFactory, 1024); |
| 158 | + |
| 159 | + MediaType contentType = new MediaType("multipart", "form-data", |
| 160 | + singletonMap("boundary", "NbjrKgjbsaMLdnMxMfDpD6myWomYc0qNX0w")); |
| 161 | + ServerHttpRequest request = MockServerHttpRequest.post("/") |
| 162 | + .contentType(contentType) |
| 163 | + .body(body); |
| 164 | + |
| 165 | + Mono<MultiValueMap<String, Part>> parts = this.reader.readMono(PARTS_ELEMENT_TYPE, request, emptyMap()); |
| 166 | + |
| 167 | + StepVerifier.create(parts) |
| 168 | + .assertNext(result -> assertThat(result).isEmpty()) |
| 169 | + .verifyComplete(); |
| 170 | + } |
| 171 | + |
152 | 172 | @Test
|
153 | 173 | public void readTooManyParts() {
|
154 | 174 | testMultipartExceptions(reader -> reader.setMaxParts(1), ex -> {
|
|
0 commit comments