Tolerate null UUID attribute values
This commit is contained in:
parent
3398955c1a
commit
bae0196bcf
|
@ -119,6 +119,6 @@ public class AttributeValues {
|
|||
}
|
||||
|
||||
public static UUID getUUID(Map<String, AttributeValue> item, String key, UUID defaultValue) {
|
||||
return AttributeValues.get(item, key).map(AttributeValues::toUUID).orElse(defaultValue);
|
||||
return AttributeValues.get(item, key).filter(av -> av.b() != null).map(AttributeValues::toUUID).orElse(defaultValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,4 +57,10 @@ public class AttributeValuesTest {
|
|||
AttributeValue av = AttributeValues.fromByteBuffer(byteBuffer.flip());
|
||||
assertArrayEquals(new byte[]{0, 0, 0, 0, 0, 0, 0, 123}, AttributeValues.getByteArray(Map.of("foo", av), "foo", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullUuid() {
|
||||
final Map<String, AttributeValue> item = Map.of("key", AttributeValue.builder().nul(true).build());
|
||||
assertNull(AttributeValues.getUUID(item, "key", null));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue