Reputation: 2500
I am looking at usage example provided in AWS SDK docs for TransferManager, in particular for the following code:
TransferManager tx = new TransferManager(
credentialProviderChain.getCredentials());
Upload myUpload = tx.upload(myBucket, myFile.getName(), myFile);
// Transfers also allow you to set a <code>ProgressListener</code> to receive
// asynchronous notifications about your transfer's progress.
myUpload.addProgressListener(myProgressListener);
and I am wondering whether we don't have here case of a race condition. AFAIU TransferManager
works asynchronously, it may start the uploading file straight away after the Upload
object creation, even before we add the listener, so if we use the snippet as provided in the docs, it seems to be possible that we won't receive all notifications. I've looked briefly into the addProgressListener
and I don't see there that past events would be replayed on attaching a new listener. Am I wrong? Am I missing something?
Upvotes: 2
Views: 999
Reputation: 42849
If you need to get ALL events, I imagine this can be achieved using a different upload
method that takes in a ProgressListener
as a parameter. Of course, using this method will require encapsulating your bucketname, key, and file into an instance of PutObjectRequest
.
Upvotes: 2