Fix unwrapping logic for ResponseEntity<Flux>

This commit makes sure that the response returned by coroutine handler
methods that return ResponseEntity<Flux> is unwrapped correctly.

Closes gh-27809
This commit is contained in:
Arjen Poutsma
2022-03-10 09:22:23 +01:00
parent af977c0891
commit a3e23cd5fc
2 changed files with 43 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Set;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.core.KotlinDetector;
@@ -130,7 +131,8 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
if (adapter != null) {
publisher = adapter.toPublisher(body);
boolean isUnwrapped = KotlinDetector.isSuspendingFunction(bodyParameter.getMethod()) &&
!COROUTINES_FLOW_CLASS_NAME.equals(bodyType.toClass().getName());
!COROUTINES_FLOW_CLASS_NAME.equals(bodyType.toClass().getName()) &&
!Flux.class.equals(bodyType.toClass());
ResolvableType genericType = isUnwrapped ? bodyType : bodyType.getGeneric();
elementType = getElementType(adapter, genericType);
actualElementType = elementType;