Skip to content

Supports builder that generated from immutables for @DynamoDbImmutable #2245

Open
@doubleseo

Description

@doubleseo

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    dynamodb-enhancedfeature-requestA feature should be added or improved.p3This is a minor priority issuethird-partyThis issue is related to third-party libraries or applications.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions