Skip to content

Commit 463c348

Browse files
committed
The CreateTable permission should not be required to use the library if the tables already exist
1 parent f48ed14 commit 463c348

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>com.dasburo</groupId>
1313
<artifactId>spring-cache-dynamodb</artifactId>
14-
<version>0.9.4</version>
14+
<version>0.9.5</version>
1515

1616
<name>Amazon DynamoDB for Spring Cache</name>
1717
<description>Spring Cache implementation based on Amazon DynamoDB</description>

src/main/java/com/dasburo/spring/cache/dynamo/DefaultDynamoCacheWriter.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,14 @@ public boolean createIfNotExists(String name, Duration ttl, Long readCapacityUni
189189
Assert.notNull(name, "Name must not be null!");
190190
Assert.notNull(ttl, "TTL must not be null! Use Duration.ZERO to disable TTL.");
191191

192-
boolean created = TableUtils.createTableIfNotExists(dynamoTemplate, createTableRequest(name, readCapacityUnits, writeCapacityUnits));
193-
if (created && !ttl.isZero()) {
194-
dynamoTemplate.updateTimeToLive(updateTimeToLiveRequest(name));
192+
boolean created = false;
193+
try {
194+
dynamoTemplate.describeTable(name);
195+
} catch(ResourceNotFoundException e) {
196+
created = TableUtils.createTableIfNotExists(dynamoTemplate, createTableRequest(name, readCapacityUnits, writeCapacityUnits));
197+
if (created && !ttl.isZero()) {
198+
dynamoTemplate.updateTimeToLive(updateTimeToLiveRequest(name));
199+
}
195200
}
196201
return created;
197202
}

0 commit comments

Comments
 (0)