diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-08-26 10:52:07 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-08-26 10:52:07 +0200 |
commit | 297bed106efdfa619d700ae44ce047d7f2663c93 (patch) | |
tree | 45c9af50b6ff7bf17eac55f7d71c9a6db762b998 /src/main/java/de | |
parent | 0ef9af997c98d0252512cc53f436709e88a1e025 (diff) |
Fixes FS#230: Uncaught NullPointerException in DNSHelper
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java index 90618292..a0fd9995 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/DNSHelper.java @@ -135,15 +135,20 @@ public class DNSHelper { Logging.d("dns", "using dns server: " + dnsServerHostAddress + " to look up " + qname); try { DNSMessage message = client.query(qname, TYPE.SRV, CLASS.IN, dnsServerHostAddress); - Record[] rrset = message.getAnswers(); - for (Record rr : rrset) { - Data d = rr.getPayload(); - if (d instanceof SRV && NameUtil.idnEquals(qname, rr.getName())) { - SRV srv = (SRV) d; - SrvRecord srvRecord = new SrvRecord(srv.getPriority(), srv.getName(), srv.getPort(), tlsSrvRecord); - result.add(srvRecord); + if (null != message) { + Record[] rrset = message.getAnswers(); + for (Record rr : rrset) { + Data d = rr.getPayload(); + if (d instanceof SRV && NameUtil.idnEquals(qname, rr.getName())) { + SRV srv = (SRV) d; + SrvRecord srvRecord = new SrvRecord(srv.getPriority(), srv.getName(), srv.getPort(), tlsSrvRecord); + result.add(srvRecord); + } } + } else { + Logging.e("dns", "No valid DNS message retrieved."); } + } catch (IOException e) { Logging.d("dns", "Error while retrieving SRV record '" + qname + "' for '" + host + "' from DNS '" + dnsServerHostAddress + "': " + e.getMessage()); } |