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.
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.