NPE in TransformingAsyncResponseHandler#onError
See original GitHub issueDescribe the bug
From time to time, we get an ERROR log from TransformingAsyncResponseHandler
telling us that there was an NPE. It does not affect our app in any way, however it feels that it shouldn’t throw that.
Expected Behavior
No log record nor NPE.
Current Behavior
We get this log statement after NPE has been raised in aws sdk core
5352c77fa1b2:2020-05-04 09:36:31,681 [speculation-executor-1] ERROR s.a.a.c.i.h.BaseAsyncClientHandler - Error thrown from TransformingAsyncResponseHandler#onError, ignoring.
5352c77fa1b2:java.lang.NullPointerException: null
5352c77fa1b2: at software.amazon.awssdk.core.internal.http.async.AsyncResponseHandler.onError(AsyncResponseHandler.java:76)
5352c77fa1b2: at software.amazon.awssdk.core.internal.http.async.CombinedResponseAsyncHttpResponseHandler.onError(CombinedResponseAsyncHttpResponseHandler.java:70)
5352c77fa1b2: at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.lambda$doExecute$3(BaseAsyncClientHandler.java:223)
5352c77fa1b2: at software.amazon.awssdk.utils.FunctionalUtils.runAndLogError(FunctionalUtils.java:40)
5352c77fa1b2: at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.doExecute(BaseAsyncClientHandler.java:220)
5352c77fa1b2: at software.amazon.awssdk.core.internal.handler.BaseAsyncClientHandler.execute(BaseAsyncClientHandler.java:86)
5352c77fa1b2: at software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler.execute(AwsAsyncClientHandler.java:52)
5352c77fa1b2: at software.amazon.awssdk.services.dynamodb.DefaultDynamoDbAsyncClient.query(DefaultDynamoDbAsyncClient.java:2707)
...
(our code)
Steps to Reproduce
I don’t know a deterministic way.
Possible Solution
I realize that the NPE comes from AsyncResponseHandler
:
@Override
public void onError(Throwable err) {
streamFuture.completeExceptionally(err);
}
where streamFuture is null, as prepare()
has not been called yet.
Context
The context is we’re doing an async requests to ddb, and for some requests we may cancel them via future.cancel()
. Apart from that we’re not doing anything special with our query requests.
Your Environment
AWS-SDK: 2.13.8 Java: 12
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:9 (1 by maintainers)
Top Results From Across the Web
TransformingAsyncResponseHa...
A response handler that returns a transformed response. Method Summary. All Methods Instance Methods Abstract Methods. Modifier and Type.
Read more >software.amazon.awssdk.core.client.handler ...
BaseAsyncClientHandler Maven / Gradle / Ivy ... t) { runAndLogError( log.logger(), "Error thrown from TransformingAsyncResponseHandler#onError, ignoring.
Read more >AWS Lambda function errors in Java
How it works · 2xx. A 2xx series error with a X-Amz-Function-Error header in the response indicates a Lambda runtime or function error....
Read more >Handling Exceptions in Project Reactor - Baeldung
Essentially, reactive streams rely on the onError method to indicate a failure condition. In most cases, this condition must be triggered by ...
Read more >AsyncResponse - Apache TomEE
Set/replace a time-out handler for the suspended asynchronous response. ... Throws: java.lang.NullPointerException - in case the callback class is null .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This reproduced the issue consistently for me:
I would expect this to throw an AbortedException/CancellationException/InterruptedException however due to the bug it’s a NullPointerException.
I am also seeing this error when attempting to call
SqsAsyncClient.receiveMessage()
. In my case, the mesage is not received. The error doesn’t occur in in v2.12.0.