-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE in software.amazon.awssdk.utils.async.InputStreamSubscriber #4081
Comments
@AlessandroPatti I see you said the error is hard to repro, but can you provide a sample code showing how you're using the InputStreamSubscriber? |
@debora-ito I am following the coursier documentation to download from a maven repository stored in a s3 bucket. The code looks very similar to this example, except it uses the sdk v2 and the |
The possible race condition makes sense. We added a task to our backlog to investigate this. |
|
Describe the bug
Occasionally seeing the following when downloading from S3
Expected Behavior
InputStreamSubscriber.close
should not raise a NPE.Current Behavior
java.lang.NullPointerException
is being thrown occasionally when closing inout stream.Reproduction Steps
It is hard to repro, as this only happens occasionally.
Possible Solution
I think there might be a race condition causing a variable to be used before it is initialised. Adding a snapshot of the relevant code from InputStreamSubscriber below:
Considering the case where two threads access the class, one invoking the
onSubscribe
and the otherclose
, it seems a race condition might cause the NPE whenThread1
invokesonSubscribe
and executes the first statement (line 58), setting the state toREADABLE
Thread2
invokesclose
afterThread1
executed line 58, but before it gets to execute line 63READABLE
,Thread2
attempts to callsubscribe.cancel()
on an unitialisedsubcriber
.Additional Information/Context
No response
AWS Java SDK version used
2.20.59
JDK version used
11
Operating System and version
MacOS 13
The text was updated successfully, but these errors were encountered: