Common overrideable method for creating a CompletableFuture #1665
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since it looks like #1543 is not going anywhere soon, i suggest a simple refactor, which will allow a reasonable client-side fix for this issue.
The workaround suggested in #1543 (comment) is to override the methods, which use the java.util.concurrent.CompletableFuture#supplyAsync() in a custom subclass of the MinioAsyncClient. As of now it's not possible, since some methods which call the CompletableFuture#supplyAsync() also use package-private classes such as io.minio.PartReader (io.minio.S3Base#putObjectAsync()) or io.minio.HttpRequestBody (io.minio.MinioAsyncClient#putObjectFanOut).
Apart from this, java.util.concurrent.CompletableFuture#supplyAsync() is used by 7 methods, once of them private. In total they make ~800 lines of code. Frankly, it would be a real pain in the ass to maintain this amount of library code copy-pasted to the application for no good reason.
This PR extracts all of the java.util.concurrent.CompletableFuture#supplyAsync() calls into a separate protected method in io.minio.S3Base. With this change everyone interested in a different way of supplying their async :) will only need to override a single short method dedicated for that sole purpose.
Please review it and let me know if you're ok with this change or if any additional changes are required