diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/util/AttributeValues.java b/service/src/main/java/org/whispersystems/textsecuregcm/util/AttributeValues.java index ab35e5e76..8cfd6ba77 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/util/AttributeValues.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/util/AttributeValues.java @@ -119,6 +119,6 @@ public class AttributeValues { } public static UUID getUUID(Map 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); } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/util/AttributeValuesTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/util/AttributeValuesTest.java index 73bb91069..b9b8115b2 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/util/AttributeValuesTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/util/AttributeValuesTest.java @@ -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 item = Map.of("key", AttributeValue.builder().nul(true).build()); + assertNull(AttributeValues.getUUID(item, "key", null)); + } }