Skip to content

AmazonDynamoDBClient exceptions cannot be caught #2092

Open
@senadmd

Description

@senadmd

Hello

We are using sdk-core:2.13.5 and sdk-ddb:2.13.4.
We have an issue catching exceptions generated by AmazonHttpClient which is used by AmazonDynamoDBClient. If for example an "NotAuthorizedException" is throw by AmazonHttpClient as shown in the attached log file, we cannot catch this exception using code as shown in "code_exception.png". The catch segment is never called.

If we try to debug the code step-by-step in android studio, the application crashes after the exception is rethrown in AmazonHttpClient and the method:
public <T> Response<T> execute(Request<?> request, HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler, HttpResponseHandler<AmazonServiceException> errorResponseHandler, ExecutionContext executionContext)

The the following is an extract from the decompiled method, i have put a comment where the application crashes during debug:
catch (final AmazonClientException e) { afterError(request, response, requestHandler2s, e); throw e; // <- CRASH HERE! }

Because of this bug we cannot handle NotAuthorizedException nor any other exception generated by AmazonDynamoDBClient.
Below is our try-catch which is never executed:
code_exception
The library prints out the following exception and stack trace which is not propagated:
log.txt

To Reproduce
An easy way to reproduce the issue (make the library generate an exception) is authenticate and sign in an user into an cognito user pool configured in awsconfiguration.json and try making an dynamoDB request that succeeds. Then try changing the awsconfiguration.json to point to a different pool and restart the app. The library should generate an "NotAuthorizedException" that cannot be caught.

Which AWS service(s) are affected?
DynamoDB

Expected behavior
The try-catch segment to be executed.

Screenshots
This shows our code and the try-catch segment which is not executed (exception is swallowed):
code_exception

Environment Information (please complete the following information):
sdk-core:2.13.5 and sdk-ddb:2.13.4 using Android

Metadata

Metadata

Assignees

No one assigned

    Labels

    dynamodbIssues with the AWS Android SDK for DynamoDB.feature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions