fixed NPE after attempt to store user@ip style jid resolver result

This commit is contained in:
Daniel Gultsch 2018-10-13 16:13:33 +02:00
parent dd1d1858d0
commit 2e2914ee78

View file

@ -301,7 +301,8 @@ public class Resolver {
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
result.ip = null; 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.port = cursor.getInt(cursor.getColumnIndex(PORT));
result.priority = cursor.getInt(cursor.getColumnIndex(PRIORITY)); result.priority = cursor.getInt(cursor.getColumnIndex(PRIORITY));
result.authenticated = cursor.getInt(cursor.getColumnIndex(AUTHENTICATED)) > 0; result.authenticated = cursor.getInt(cursor.getColumnIndex(AUTHENTICATED)) > 0;
@ -393,7 +394,7 @@ public class Resolver {
public ContentValues toContentValues() { public ContentValues toContentValues() {
final ContentValues contentValues = new ContentValues(); final ContentValues contentValues = new ContentValues();
contentValues.put(IP, ip == null ? null : ip.getAddress()); 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(PORT, port);
contentValues.put(PRIORITY, priority); contentValues.put(PRIORITY, priority);
contentValues.put(DIRECT_TLS, directTls ? 1 : 0); contentValues.put(DIRECT_TLS, directTls ? 1 : 0);