Mono<Void>.flatMap is not getting invoked when it returns Mono<Something>
Mono<Void>
doesn't produce a value because Void is not an object. Basically, it's the same as an empty Mono; it just completes without any actual element.
As per docs: https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html
Mono<Void> should be used for Publisher that just completes without any value.
So a flatMap
, as well as any other method that is supposed to process a value, would never be called after Mono.just(music).then().flatMap
.
But if you just want to update and return the value you already have, then you can do:
return filePart.transferTo(file).then(Mono.defer({ music.setFilePath(file.getAbsolutePath()); music.setMeta(new Metadata()); log.info(String.valueOf(music)); // assuming .save returns a publisher return this.musicRepository.save(music); });