[BUG] Blob Storage's downloadToFile deletes files after `toFuture` is called
See original GitHub issueDescribe the bug
After calling downloadToFile
(with or without overwrite = true), the operation succeeds, and the file, for a brief moment, is successfully downloaded and persisted on disk. However, if a toFuture
subscriber is attached and then subsequently converted to a Scala Future (using either Scala’s built in compat, or via Reactor’s Scala extensions), a cancel
signal is fired, and the handler here fires and deletes the file:
https://github.com/Azure/azure-sdk-for-java/blob/b59f999110e7a12004b51918b04b7ede444824a5/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java#L1039
edit - quick update - Mono’s toFuture
does indeed fire off a cancel: https://github.com/reactor/reactor-core/blob/c6b75f2578ee5f201ac06add2239322cc5b7bfcd/reactor-core/src/main/java/reactor/core/publisher/MonoToCompletableFuture.java#L59, which makes the downloadToFile
methods impossible to use if a CompletableFuture is desired. May I suggest loosening the check for deletion? 😄
I’m not very familiar with Reactor, and would be happy to find out if I’m doing something wrong, or if there’s a workaround. We are on a Scala codebase that relies heavily on Futures, so not using a Future is not quite an option.
Exception or Stack Trace N/A
To Reproduce Steps to reproduce the behavior: See the following snippet
Code Snippet
blobContainerClient
.getBlobAsyncClient(myBlobKey)
.downloadToFile("my/path")
.onComplete { ...file is fine here... }
.doFinally { ... eventually `cancel` is fired instead of `complete` ... }
.toFuture.asScala.map { ... file disappears ... }
Expected behavior Don’t delete my file 😦
Screenshots N/A
Setup (please complete the following information):
- OS: macOS Catalina
- IDE : Intellij Ultimate
- Version of the Library used: 12.4.0
Additional context Could be related to https://github.com/spring-projects/spring-framework/issues/22952, even though this appears to be fixed?
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- Repro Steps Added
- Setup information Added
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Can this issue be closed?
The issue is fixed in the reactor-core.