From c5da699afeb2b9e1925daecac10ff0a30b5d339f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 20 Apr 2020 15:53:52 +0200 Subject: [PATCH] dont crash when fields names in caps are null --- .../conversations/entities/ServiceDiscoveryResult.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java b/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java index c4babe81c..d0bdb5632 100644 --- a/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java +++ b/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java @@ -6,6 +6,8 @@ import android.support.annotation.NonNull; import android.util.Base64; import android.util.Log; +import com.google.common.base.Strings; + import java.io.UnsupportedEncodingException; import java.lang.Comparable; import java.security.MessageDigest; @@ -222,9 +224,9 @@ public class ServiceDiscoveryResult { for (Data form : forms) { s.append(clean(form.getFormType())).append("<"); List fields = form.getFields(); - Collections.sort(fields, (lhs, rhs) -> lhs.getFieldName().compareTo(rhs.getFieldName())); + Collections.sort(fields, (lhs, rhs) -> Strings.nullToEmpty(lhs.getFieldName()).compareTo(Strings.nullToEmpty(rhs.getFieldName()))); for (Field field : fields) { - s.append(clean(field.getFieldName())).append("<"); + s.append(Strings.nullToEmpty(field.getFieldName())).append("<"); List values = field.getValues(); Collections.sort(values); for (String value : values) {