Merge pull request #32141 from kzander91

* pr/32141:
  Polish "Simplify use of Reactor's cast operator"
  Simplify use of Reactor's cast operator

Closes gh-32141
This commit is contained in:
Stéphane Nicoll 2024-01-27 12:23:24 +01:00
commit a7764dc61d
2 changed files with 4 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 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.
@ -167,9 +167,8 @@ public class PartEventHttpMessageReader extends LoggingCodecSupport implements H
Assert.state(headersToken != null, "Signal should be headers token"); Assert.state(headersToken != null, "Signal should be headers token");
HttpHeaders headers = headersToken.headers(); HttpHeaders headers = headersToken.headers();
Flux<MultipartParser.BodyToken> bodyTokens = Flux<MultipartParser.BodyToken> bodyTokens = flux.ofType(
flux.filter(t -> t instanceof MultipartParser.BodyToken) MultipartParser.BodyToken.class);
.cast(MultipartParser.BodyToken.class);
return createEvents(headers, bodyTokens); return createEvents(headers, bodyTokens);
} }
else { else {

View File

@ -240,9 +240,8 @@ class MultipartRouterFunctionIntegrationTests extends AbstractRouterFunctionInte
public Mono<ServerResponse> transferTo(ServerRequest request) { public Mono<ServerResponse> transferTo(ServerRequest request) {
return request.body(BodyExtractors.toParts()) return request.body(BodyExtractors.toParts())
.filter(FilePart.class::isInstance) .ofType(FilePart.class)
.next() .next()
.cast(FilePart.class)
.flatMap(part -> createTempFile() .flatMap(part -> createTempFile()
.flatMap(tempFile -> .flatMap(tempFile ->
part.transferTo(tempFile) part.transferTo(tempFile)