in src/main/java/com/amazonaws/services/dynamodbv2/transactions/TransactionDynamoDBFacade.java [113:140]
private void checkExpectedValues(String tableName,
Map<String, AttributeValue> itemKey,
Map<String, ExpectedAttributeValue> expectedValues) {
if (expectedValues != null && !expectedValues.isEmpty()) {
for (Map.Entry<String, ExpectedAttributeValue> entry : expectedValues.entrySet()) {
if ((entry.getValue().isExists() == null || entry.getValue().isExists() == true)
&& entry.getValue().getValue() == null) {
throw new IllegalArgumentException("An explicit value is required when Exists is null or true, "
+ "but none was found in expected values for item with key " + itemKey +
": " + expectedValues);
}
}
// simulate by loading the item and checking the values;
// this also has the effect of locking the item, which gives the
// same behavior
GetItemResult result = getItem(new GetItemRequest()
.withAttributesToGet(expectedValues.keySet())
.withKey(itemKey)
.withTableName(tableName));
Map<String, AttributeValue> item = result.getItem();
try {
checkExpectedValues(expectedValues, item);
} catch (ConditionalCheckFailedException e) {
throw new ConditionalCheckFailedException("Item " + itemKey + " had unexpected attributes: " + e.getMessage());
}
}
}