Skip to content

Commit 95a2b5a

Browse files
committed
Handle race condition in CRT tx pause
If S3MetaRequestPauseObservable#pause is invoked before S3MetaRequestPauseObservable#subscribe is executed, an NPE can occur. This can happen if the transfer hasn't actually begin before the pause() was invoked. Fix this by returning `null` in this case, which `CrtFileUpload` treats as transfer not yet started.
1 parent bf44954 commit 95a2b5a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

services/s3/src/main/java/software/amazon/awssdk/services/s3/internal/crt/S3MetaRequestPauseObservable.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public void subscribe(S3MetaRequestWrapper request) {
4343
* Pause the request
4444
*/
4545
public ResumeToken pause() {
46-
return pause.apply(request);
46+
S3MetaRequestWrapper r = this.request;
47+
if (r != null) {
48+
return pause.apply(r);
49+
}
50+
return null;
4751
}
4852
}
4953

0 commit comments

Comments
 (0)