Affects: \<6.0.15>

The code is below, 1. return a Flux object wrapped response in the exchangeToFlux block 2. use response.bodyToFlux as input to another Request 3. It always triggers the error RuntimeException("no elements")

 WebClient.create()
            .get()
            .uri(URI.create(downloadLink))
            .headers { downHeaders ->
                downHeaders.addAll(downloadHeaders)
            }
            .exchangeToFlux {
                return@exchangeToFlux Flux.just(it)
            }
            .flatMap { resp ->

                return@flatMap  Flux.from(
                    WebClient.create()
                        .method(method)
                        .uri(URI.create(uploadLink))
                        .headers { upHeaders ->

                            val httpHeaders = resp.headers().asHttpHeaders()
                            upHeaders.addAll(uploadHeaders)
                            upHeaders[HttpHeaders.CONTENT_TYPE] = httpHeaders[HttpHeaders.CONTENT_TYPE]
                            // without content-length,s3 returns s3 501 not implemented
                            upHeaders[HttpHeaders.CONTENT_LENGTH] = httpHeaders[HttpHeaders.CONTENT_LENGTH]
                        }
                        .body(resp.bodyToFlux(DataBuffer::class.java).switchIfEmpty {
                            it.onError(RuntimeException("no elements"))
                        }, DataBuffer::class.java)
                        .retrieve()
                        .bodyToMono(returnType)

After I changed as the below, however, it works

WebClient.create()
            .get()
            .uri(URI.create(downloadLink))
            .headers { downHeaders ->
                downHeaders.addAll(downloadHeaders)
            }
            .exchangeToFlux { resp ->

                return@exchangeToFlux  Flux.from(
                    WebClient.create()
                        .method(method)
                        .uri(URI.create(uploadLink))
                        .headers { upHeaders ->

                            val httpHeaders = resp.headers().asHttpHeaders()
                            upHeaders.addAll(uploadHeaders)
                            upHeaders[HttpHeaders.CONTENT_TYPE] = httpHeaders[HttpHeaders.CONTENT_TYPE]
                            // without content-length,s3 returns s3 501 not implemented
                            upHeaders[HttpHeaders.CONTENT_LENGTH] = httpHeaders[HttpHeaders.CONTENT_LENGTH]
                        }
                        .body(resp.bodyToFlux(DataBuffer::class.java).switchIfEmpty {
                            it.onError(RuntimeException("no elements"))
                        }, DataBuffer::class.java)
                        .retrieve()
                        .bodyToMono(returnType)
                )
            }

Comment From: sdeleuze

Please provide a reproducer as an attached project or a link to a repository, as well as more details on why you think there is a Spring bug involved, rather than a potential misuse of the Reactive API.