Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

IllegalArgumentException: Duplicated keys in MtAmazonDynamoDbBySharedTable.batchGetItem #802

@ifedorenko

Description

@ifedorenko

This test (as part of MtAmazonDynamoDbBySharedTableTest)

    @ParameterizedTest(name = "{arguments}")
    @ArgumentsSource(ListVirtualTableProvider.class)
    public void testBatchGetItem_multipleVirtualTables(TestArgument testArgument) {
        AmazonDynamoDB db = testArgument.getAmazonDynamoDb();
        Runnable test = () -> {
            db.createTable(new CreateTableRequest()
                .withTableName("t1")
                .withKeySchema(new KeySchemaElement("pk", HASH))
                .withAttributeDefinitions(new AttributeDefinition("pk", S)));
            db.putItem(new PutItemRequest()
                .withTableName("t1")
                .withItem(ImmutableMap.of("pk", new AttributeValue("pkval"))));

            db.createTable(new CreateTableRequest()
                .withTableName("t2")
                .withKeySchema(new KeySchemaElement("pk", HASH))
                .withAttributeDefinitions(new AttributeDefinition("pk", S)));
            db.putItem(new PutItemRequest()
                .withTableName("t2")
                .withItem(ImmutableMap.of("pk", new AttributeValue("pkval"))));

            BatchGetItemResult result = db.batchGetItem(new BatchGetItemRequest(ImmutableMap.of(
                "t1", new KeysAndAttributes().withKeys(ImmutableMap.of("pk", new AttributeValue("pkval"))),
                "t2", new KeysAndAttributes().withKeys(ImmutableMap.of("pk", new AttributeValue("pkval")))
            )));

            assertEquals(ImmutableSet.of("t1", "t2"), result.getResponses().keySet());
        };
        MT_CONTEXT.withContext("org", test);
    }

fails with the exception below

java.lang.IllegalArgumentException: Duplicated keys (mt_shared_table_static_s_no_lsi) are provided.

	at com.amazonaws.services.dynamodbv2.model.BatchGetItemRequest.addRequestItemsEntry(BatchGetItemRequest.java:1270)
	at com.salesforce.dynamodbv2.mt.mappers.sharedtable.impl.MtAmazonDynamoDbBySharedTable.lambda$batchGetItem$3(MtAmazonDynamoDbBySharedTable.java:258)
	at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:185)
	at com.salesforce.dynamodbv2.mt.mappers.sharedtable.impl.MtAmazonDynamoDbBySharedTable.batchGetItem(MtAmazonDynamoDbBySharedTable.java:252)
	at com.salesforce.dynamodbv2.mt.mappers.sharedtable.impl.MtAmazonDynamoDbBySharedTableTest.lambda$testBatchGetItem_multipleVirtualTables$4(MtAmazonDynamoDbBySharedTableTest.java:272)
	at com.salesforce.dynamodbv2.mt.context.MtAmazonDynamoDbContextProvider.withContext(MtAmazonDynamoDbContextProvider.java:63)
	at com.salesforce.dynamodbv2.mt.mappers.sharedtable.impl.MtAmazonDynamoDbBySharedTableTest.testBatchGetItem_multipleVirtualTables(MtAmazonDynamoDbBySharedTableTest.java:279)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestTemplateMethod(TimeoutExtension.java:92)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask$DefaultDynamicTestExecutor.execute(NodeTestTask.java:198)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:138)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$2(TestTemplateTestDescriptor.java:106)

Need to either officially "desupport" multi-table batchGetItem requests (my vote) or fix the implementation to correctly map request and response items.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions