From 2e2914ee78ea726a97df202247d29230abb7075a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 13 Oct 2018 16:13:33 +0200 Subject: [PATCH] fixed NPE after attempt to store user@ip style jid resolver result --- src/main/java/eu/siacs/conversations/utils/Resolver.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/Resolver.java b/src/main/java/eu/siacs/conversations/utils/Resolver.java index eba1652cc..1b8e28374 100644 --- a/src/main/java/eu/siacs/conversations/utils/Resolver.java +++ b/src/main/java/eu/siacs/conversations/utils/Resolver.java @@ -301,7 +301,8 @@ public class Resolver { } catch (UnknownHostException e) { result.ip = null; } - result.hostname = DNSName.from(cursor.getString(cursor.getColumnIndex(HOSTNAME))); + final String hostname = cursor.getString(cursor.getColumnIndex(HOSTNAME)); + result.hostname = hostname == null ? null : DNSName.from(hostname); result.port = cursor.getInt(cursor.getColumnIndex(PORT)); result.priority = cursor.getInt(cursor.getColumnIndex(PRIORITY)); result.authenticated = cursor.getInt(cursor.getColumnIndex(AUTHENTICATED)) > 0; @@ -393,7 +394,7 @@ public class Resolver { public ContentValues toContentValues() { final ContentValues contentValues = new ContentValues(); contentValues.put(IP, ip == null ? null : ip.getAddress()); - contentValues.put(HOSTNAME, hostname.toString()); + contentValues.put(HOSTNAME, hostname == null ? null : hostname.toString()); contentValues.put(PORT, port); contentValues.put(PRIORITY, priority); contentValues.put(DIRECT_TLS, directTls ? 1 : 0);