question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE in TransformingAsyncResponseHandler#onError

See original GitHub issue

Describe 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:open
  • Created 3 years ago
  • Reactions:11
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
RealTYPICALcommented, Feb 11, 2021

This reproduced the issue consistently for me:

S3AsyncClient s3AsyncClient = S3AsyncClient.create();

Thread thread = new Thread(() -> s3AsyncClient.copyObject(CopyObjectRequest.builder().build()));

thread.interrupt();
thread.start();
thread.join();

I would expect this to throw an AbortedException/CancellationException/InterruptedException however due to the bug it’s a NullPointerException.

1reaction
adamucommented, May 19, 2020

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.

ERROR [sof.ama.aws.cor.int.han.BaseAsyncClientHandler] (executor-thread-1) Error thrown from TransformingAsyncResponseHandler#onError, ignoring.: 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)
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found