Source:
public <T extends Item> T create(final T item) { final ItemConfiguration itemConfiguration = getItemConfiguration(item.getClass()); final Collection<PropertyDescriptor> createdConstraintPropertyDescriptors = createUniqueConstraintIndexes(item, itemConfiguration); final Map<String, ExpectedAttributeValue> expectedResults = new HashMap<>(); expectedResults.put(itemConfiguration.primaryKeyDefinition().propertyName(), new ExpectedAttributeValue(false)); final Map<String, AttributeValue> attributeMap = getAttributeMap(item, itemConfiguration, 1l); final String tableName = databaseSchemaHolder.schemaName() + "." + itemConfiguration.tableName(); final PutItemRequest itemRequest = new PutItemRequest().withTableName(tableName).withItem(attributeMap) .withExpected(expectedResults); try { amazonDynamoDbClient.putItem(itemRequest); } catch (final ConditionalCheckFailedException conditionalCheckFailedException) { try { deleteUniqueConstraintIndexes(item, itemConfiguration, createdConstraintPropertyDescriptors); } catch (final Exception deleteUniqueConstraintIndexesException) { logger.error(deleteUniqueConstraintIndexesException.getMessage(), deleteUniqueConstraintIndexesException); } throw new ItemConstraintViolationException(itemConfiguration.primaryKeyDefinition().propertyName(), "Failure to create item as store already contains item with matching primary key"); } catch (final AmazonServiceException amazonServiceException) { try { deleteUniqueConstraintIndexes(item, itemConfiguration, createdConstraintPropertyDescriptors); } catch (final Exception deleteUniqueConstraintIndexesException) { logger.error(deleteUniqueConstraintIndexesException.getMessage(), deleteUniqueConstraintIndexesException); } throw new PersistenceResourceFailureException("Failure while attempting DynamoDb put (create)", amazonServiceException); } item.setVersion(1l); return item; }

Target:
public <T extends Item> T create(final T item) { final ItemConfiguration itemConfiguration = getItemConfiguration(item.getClass()); final Collection<PropertyDescriptor> createdConstraintPropertyDescriptors = createUniqueConstraintIndexes(item, itemConfiguration); final Map<String, ExpectedAttributeValue> expectedResults = new HashMap<>(); expectedResults.put(itemConfiguration.primaryKeyDefinition().propertyName(), new ExpectedAttributeValue(false)); final Map<String, AttributeValue> attributeMap = getAttributeMap(item, itemConfiguration, 1l); final String tableName = databaseSchemaHolder.schemaName() + "." + itemConfiguration.tableName(); final PutItemRequest itemRequest = new PutItemRequest().withTableName(tableName).withItem(attributeMap) .withExpected(expectedResults); boolean itemRequestSucceeded = false; try { amazonDynamoDbClient.putItem(itemRequest); itemRequestSucceeded = true; } catch (final ConditionalCheckFailedException conditionalCheckFailedException) { throw new ItemConstraintViolationException(itemConfiguration.primaryKeyDefinition().propertyName(), "Failure to create item as store already contains item with matching primary key"); } catch (final AmazonServiceException amazonServiceException) { throw new PersistenceResourceFailureException("Failure while attempting DynamoDb put (create)", amazonServiceException); } finally { if (!itemRequestSucceeded) { try { deleteUniqueConstraintIndexes(item, itemConfiguration, createdConstraintPropertyDescriptors); } catch (final Exception deleteUniqueConstraintIndexesException) { logger.error(deleteUniqueConstraintIndexesException.getMessage(), deleteUniqueConstraintIndexesException); } } } item.setVersion(1l); return item; }