Skip to content
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

Cannot invoke the close method on DynamoDBLocal client (aws-sdk-java-v2) #3633

Closed
oleksii-syromolotov opened this issue Dec 15, 2022 · 4 comments
Assignees
Labels
bug This issue is a bug. dynamodb-local p3 This is a minor priority issue

Comments

@oleksii-syromolotov
Copy link

oleksii-syromolotov commented Dec 15, 2022

Describe the bug

We are using com.amazonaws:DynamoDBLocal:1.16.0.
We have the IllegalArgumentException when trying to invoke method close on DynamoDBLocal client (instance of com.amazonaws.services.dynamodbv2.local.shared.access.LocalDBClient).

Expected Behavior

The client should be closed, the test should be marked as passed.the

Current Behavior

object is not an instance of declaring class
java.lang.IllegalArgumentException: object is not an instance of declaring class
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.amazonaws.services.dynamodbv2.local.embedded.DDBExceptionMappingInvocationHandler.invoke(DDBExceptionMappingInvocationHandler.java:85)
	at com.sun.proxy.$Proxy35.close(Unknown Source)
	at com.company.aws.services.dynamodbv2.local.embedded.MyTestClass.closeShouldWork(MyTestClass.java:55)

Reproduction Steps

Dependencies

implementation "software.amazon.awssdk:sdk-core:2.18.38"
implementation "software.amazon.awssdk:dynamodb:2.18.38"
implementation "com.amazonaws:DynamoDBLocal:1.16.0"

MyTestClass:

@Test
public void closeShouldWork() {
    DynamoDbClient dynamoDbClientEmbedded = DynamoDBEmbedded.create().dynamoDbClient();
    dynamoDbClientEmbedded.close();
}

Possible Solution

In com.amazonaws.services.dynamodbv2.local.embedded.DDBExceptionMappingInvocationHandler#invoke we can see some conditional logic:

if (AmazonDynamoDB.class.equals(method.getDeclaringClass())) {
    result = method.invoke(this.impl.amazonDynamoDB(), args);
} else if (AmazonDynamoDBStreams.class.equals(method.getDeclaringClass())) {
    result = method.invoke(this.impl.amazonDynamoDBStreams(), args);
} else if (DynamoDbClient.class.equals(method.getDeclaringClass())) {
    isAWSSdkV2 = true;
    result = method.invoke(this.impl.dynamoDbClient(), args);
} else if (DynamoDbAsyncClient.class.equals(method.getDeclaringClass())) {
    isAWSSdkV2 = true;
    result = method.invoke(this.impl.dynamoDbAsyncClient(), args);
} else if (DynamoDbStreamsClient.class.equals(method.getDeclaringClass())) {
    isAWSSdkV2 = true;
    result = method.invoke(this.impl.dynamoDbStreamsClient(), args);
} else if (DynamoDbStreamsAsyncClient.class.equals(method.getDeclaringClass())) {
    isAWSSdkV2 = true;
    result = method.invoke(this.impl.dynamoDbAsyncClient(), args);
} else {
    result = method.invoke(this.impl, args);
}

Here we can see that the client choice for method invocation depends on what class the method belongs to. And the default case is to invoke method on this.impl (instance of LocalDBClient and obviously has not close method).

Additional Information/Context

No response

AWS Java SDK version used

2.18.38

JDK version used

openjdk version "1.8.0_322"
OpenJDK Runtime Environment Corretto-8.322.06.1 (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM Corretto-8.322.06.1 (build 25.322-b06, mixed mode)

Operating System and version

Windows 10

@oleksii-syromolotov oleksii-syromolotov added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 15, 2022
@oleksii-syromolotov
Copy link
Author

P.S. I know that this is not DynamoDbLocal repo, but I wasn`t able to find one. But I also saw that some people found help here in their issues with DynamoDbLocal. Like here - issue 982

@yasminetalby yasminetalby self-assigned this Dec 19, 2022
@yasminetalby
Copy link

Hello @oleksii-syromolotov ,

Thank you very much for reaching out.
You are right DynamoDbLocal is not owned by the AWS Java SDK Team but we can definitely reach out to the team owner.
I have opened a ticket to the service team regarding this behavior and will post all update here.

Thank you for your submission!

Sincerely,

Yasmine.

@yasminetalby yasminetalby added third-party This issue is related to third-party libraries or applications. and removed needs-triage This issue or PR still needs to be triaged. third-party This issue is related to third-party libraries or applications. labels Dec 19, 2022
@debora-ito debora-ito added the p3 This is a minor priority issue label Mar 27, 2023
@debora-ito
Copy link
Member

@oleksii-syromolotov The DynamoDB Local team released a fix, it's available as of today.

Closing this issue.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. dynamodb-local p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

3 participants