Skip to content

Commit 79a3896

Browse files
committed
Allow passing empty indices list to CreateTableOperation (aws#3923)
* CreateTableRequest cannot handle empty list of indices of any type. It throws exception when given such a list. At the same time, it nicely handles the cases when indices lists are null. Make sure then that when empty indices list is passed CreateTableOperation, then in the CreateTableRequest it's just reflected as null.
1 parent 0d77cea commit 79a3896

File tree

1 file changed

+2
-2
lines changed
  • services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations

1 file changed

+2
-2
lines changed

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/operations/CreateTableOperation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public CreateTableRequest generateRequest(TableSchema<T> tableSchema,
7474
List<software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndex> sdkGlobalSecondaryIndices = null;
7575
List<software.amazon.awssdk.services.dynamodb.model.LocalSecondaryIndex> sdkLocalSecondaryIndices = null;
7676

77-
if (this.request.globalSecondaryIndices() != null) {
77+
if (this.request.globalSecondaryIndices() != null && !this.request.globalSecondaryIndices().isEmpty()) {
7878
sdkGlobalSecondaryIndices =
7979
this.request.globalSecondaryIndices().stream().map(gsi -> {
8080
String indexPartitionKey = tableSchema.tableMetadata().indexPartitionKey(gsi.indexName());
@@ -92,7 +92,7 @@ public CreateTableRequest generateRequest(TableSchema<T> tableSchema,
9292
}).collect(Collectors.toList());
9393
}
9494

95-
if (this.request.localSecondaryIndices() != null) {
95+
if (this.request.localSecondaryIndices() != null && !this.request.localSecondaryIndices().isEmpty()) {
9696
sdkLocalSecondaryIndices =
9797
this.request.localSecondaryIndices().stream().map(lsi -> {
9898
Optional<String> indexSortKey = tableSchema.tableMetadata().indexSortKey(lsi.indexName());

0 commit comments

Comments
 (0)