Skip to content

Commit 12951c3

Browse files
committed
Prevents NPE when Gson deserializes unknown enum values as null entries in the Set<ContactProximity>
1 parent 7066d67 commit 12951c3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

sormas-app/app/src/main/java/de/symeda/sormas/app/contact/edit/ContactNewFragment.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ private void updateContactCategory(FragmentContactNewLayoutBinding contentBindin
162162
ContactCategory highestCategory = null;
163163
if (proximities != null) {
164164
for (ContactProximity proximity : proximities) {
165+
if (proximity == null) {
166+
continue;
167+
}
165168
ContactCategory category = getContactCategoryForProximity(proximity);
166169
if (category != null && (highestCategory == null || category.ordinal() < highestCategory.ordinal())) {
167170
highestCategory = category;
@@ -172,6 +175,9 @@ private void updateContactCategory(FragmentContactNewLayoutBinding contentBindin
172175
}
173176

174177
private ContactCategory getContactCategoryForProximity(ContactProximity proximity) {
178+
if (proximity == null) {
179+
return null;
180+
}
175181
switch (proximity) {
176182
case FACE_TO_FACE_LONG:
177183
case TOUCHED_FLUID:

0 commit comments

Comments
 (0)