I have rather simple Kotlin code which always blocks and never returns:
WebClient
.create()
.get()
.uri("https://httpbin.org/status/200")
.exchange()
.flatMap {
println("Status ${it.statusCode()}")
it.bodyToMono(String::class.java)
}
.timeout(Duration.ofSeconds(5), Mono.just("fallback"))
.map { println("Response $it") } // never runs
.block()
httpbinin this case returns no content (only headers), so is that so thatbodyToMonowaits forever for the content here? Is there solid way how to handle such case (reading Content-Length is not reliable)I set Mono.timeout with fallback value, why doesn't it cover that?