Skip to content

Added null protection for streamFuture after we saw a NPE in AsyncResponseHandler.onError() #2279

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

Closed
wants to merge 1 commit into from

Conversation

j256
Copy link

@j256 j256 commented Feb 11, 2021

Seems like there is a way for onError() to be called before prepare() where streamFuture is initialized.

Description

Added a null check around the use of streamFuture. Here's the full exception stack. This is from code from an earlier version.

java.lang.NullPointerException
 	at software.amazon.awssdk.core.internal.http.async.AsyncResponseHandler.onError(AsyncResponseHandler.java:76)
 	at software.amazon.awssdk.core.internal.http.async.CombinedResponseAsyncHttpResponseHandler.onError(CombinedResponseAsyncHttpResponseHandler.java:70)
 	at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.lambda$doExecute$3(BaseAsyncClientHandler.java:223)
 	at software.amazon.awssdk.utils.FunctionalUtils.runAndLogError(FunctionalUtils.java:40)
 	at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.doExecute(BaseAsyncClientHandler.java:220)
 	at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.execute(BaseAsyncClientHandler.java:86)
 	at software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler.execute(AwsAsyncClientHandler.java:52)
 	at software.amazon.awssdk.services.sqs.DefaultSqsAsyncClient.receiveMessage(DefaultSqsAsyncClient.java:1149)

Motivation and Context

We saw a NPE on that line.

Testing

Don't see the need for testing this sort of change.

Screenshots (if appropriate)

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@j256 j256 changed the title We just saw a NPE on this line so added protection. We just saw a NPE in AsyncResponseHandler.onError() so added null protection for streamFuture Feb 11, 2021
@j256 j256 changed the title We just saw a NPE in AsyncResponseHandler.onError() so added null protection for streamFuture Added null protection for streamFuture after we saw a NPE in AsyncResponseHandler.onError() Feb 11, 2021
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@dagnir
Copy link
Contributor

dagnir commented Feb 17, 2021

Hi, thank you for the pull request! Unfortunately, I don't think this is the right fix for the issue. The SPI guarantees that prepare() is always called before the other methods so the implementation should be able to rely on this and not need the null check.

@j256
Copy link
Author

j256 commented Feb 18, 2021

Well I've seen this in the wild so it seems crazy not to include it.

@dagnir
Copy link
Contributor

dagnir commented Feb 18, 2021

Sorry I only mean that the root cause is the core library isn't properly upholding the SPI guarantees somewhere. This issue is currently being tracked in #1812.

@j256
Copy link
Author

j256 commented Feb 18, 2021

Belt and suspenders is my moto.

@debora-ito
Copy link
Member

Will close this PR as stale.

We might have fixed this issue after the refactor released in 2.21.x but still need to confirm.
Please check #1812 for updates.

@debora-ito debora-ito closed this Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants