aws / aws/aws-sdk-java-v2

Supports builder that generated from immutables for @DynamoDbImmutable

Aperta
#2,245 3 commenti 1 reazione 0 assegnatari Vedi su GitHub
dynamodb-enhanced feature-request p3 third-party
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

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:

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with software.amazon.awssdk.enhanced.dynamodb.internal.immutable.ImmutableIntrospector.java at filterAndIndexBuilderMethods (line 164), then trace how ImmutableTableSchema.createStaticImmutableTableSchema invokes it. Reproduce the failure with an Immutables-generated builder containing collection or optional initialization methods, and verify that schema creation no longer fails with a duplicate-key validation error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, java
Ambito
databases
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.