aws / aws/aws-sdk-java-v2

Supports builder that generated from immutables for @DynamoDbImmutable

Open
#2,245 3 comments 1 reaction 0 assignees View on GitHub
dynamodb-enhanced feature-request p3 third-party
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

Supports builder that generated from immutables for @DynamoDbImmutable
See more information about Immutables see here: https://immutables.github.io/

## Expected Behavior
DDB Enhanced Client does not throws validation error when builder has more than one initialize methods per attribute.

## Current Behavior
Immutables's builder generates couple of special methods to initialize collection or optional attributes:
https://immutables.github.io/immutable.html#array-collection-and-map-attributes
https://immutables.github.io/immutable.html#optional-attributes

However, DDB Enhanced Client throws IllegalStateException exception due to Duplicate Key on the special methods.

```
java.lang.IllegalStateException: Duplicate key ...
at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:133)
at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableIntrospector.filterAndIndexBuilderMethods(ImmutableIntrospector.java:164)
at software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableIntrospector.introspect(ImmutableIntrospector.java:67)
at software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableIntrospector.getImmutableInfo(ImmutableIntrospector.java:60)
at software.amazon.awssdk.enhanced.dynamodb.mapper.ImmutableTableSchema.createStaticImmutableTableSchema(ImmutableTableSchema.java:154)
at software.amazon.awssdk.enhanced.dynamodb.mapper.ImmutableTableSchema.create(ImmutableTableSchema.java:125)
```

## Context
We use Immutables to define the object to immutable and generate builder automatically. We do not use lombok due to a policy for the code generation. If we cannot use Immutables, then we should copy-paste and hard code builder on the model in order to use @DynamoDbImmutable.

## Your Environment

* AWS Java SDK version used: v2 AWS SDK
* JDK version used: JDK11
* Operating System and version:

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.