mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 15:52:06 +01:00
Fix MiniDnsResolver NPE when query returns 'null'
This commit is contained in:
parent
a90c1ac845
commit
79380e189e
1 changed files with 3 additions and 0 deletions
|
@ -77,6 +77,9 @@ public class MiniDnsResolver extends SmackAndOsgiInitializer implements DNSResol
|
||||||
public List<SRVRecord> lookupSRVRecords(String name) {
|
public List<SRVRecord> lookupSRVRecords(String name) {
|
||||||
List<SRVRecord> res = new LinkedList<SRVRecord>();
|
List<SRVRecord> res = new LinkedList<SRVRecord>();
|
||||||
DNSMessage message = client.query(name, TYPE.SRV, CLASS.IN);
|
DNSMessage message = client.query(name, TYPE.SRV, CLASS.IN);
|
||||||
|
if (message == null) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
for (Record record : message.getAnswers()) {
|
for (Record record : message.getAnswers()) {
|
||||||
SRV srv = (SRV) record.getPayload();
|
SRV srv = (SRV) record.getPayload();
|
||||||
res.add(new SRVRecord(srv.getName(), srv.getPort(), srv.getPriority(), srv.getWeight()));
|
res.add(new SRVRecord(srv.getName(), srv.getPort(), srv.getPriority(), srv.getWeight()));
|
||||||
|
|
Loading…
Reference in a new issue