mygrocerydeals / gradle-s3-plugin

Gradle plugin that uploads and downloads S3 objects.
MIT License
3 stars 11 forks source link

Large files and multiple file uploads/downloads do not work because TransferManager is GC'ed. #4

Closed chubbard closed 2 years ago

chubbard commented 3 years ago

You have to keep a reference to the TransferManager while your transfers are happening or else it will be GC'ed causing all transfers to be interrupted. This now stores off that reference and then shuts it down in a finally block after the waitForCompletion() returns.

This fixes 2 issues. One is that large files would be truncated because the TransferManager kills then when it's GC'ed. And it also fixes a RejectedException being thrown while trying to download more files than there are background jobs and the TransferManager gets GC'ed in the middle of it. Both of these scenarios make it more likely that the TransferManager would be GC'ed causes the different issues.