I would like to create a temp file in a reactive way to avoid blocking calls.
Mono.fromCallable {
Files.createTempFile(null, ".zip")
}
.flatMap { path: Path ->
DataBufferUtils.write(
webclient.get().uri("/large-file.zip").retrieve()
.bodyToFlux(DataBuffer::class.java),
path,
StandardOpenOption.CREATE
).then(Mono.just(path))
}
However, I get warning in IDEA on method createTempFile
:
Possibly blocking call in non-blocking context could lead to thread starvation
Is there a way to create such file in truly reactive way?