aws / aws/aws-sdk-java-v2

Singleton DynamoDbEnhancedAsyncClient/DynamoDbAsyncTable and versioned records

Open
#2,559 6 comments 3 reactions 0 assignees View on GitHub
feature-request p3
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

One way of having instances of `DynamoDbEnhancedAsyncClient` or `DynamoDbAsyncTable` in an app is to declare them as singletons and inject whenever needed. At the same time `DynamoDbEnhancedAsyncClient` and `DynamoDbAsyncTable` can be used to execute both regular `get` / `update` / `delete` as well as batch `get` / `write` operations. If an entity for which the `AsyncClient` / `AsyncTable` instances are created (with default settings) has a version attribute, an attempt to execute batch `get` / `write` operation will cause `IllegalArgumentException("A mapper extension inserted a conditionExpression in a PutItem...")` error and regular operations would work just fine. Suggested workarounds are either use a table schema without the versioned attribute or do not load `VersionedRecordExtension` extension (loaded by default).

Is it possible to make `VersionedRecordExtension` "context-aware", so that it won't insert condition expression when it's called as part of the `put item` operation? Or `DynamoDbEnhancedAsyncClient` and `DynamoDbAsyncTable` instances aren't supposed to be shared across an app and should be created closer to the place where they are used?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.