1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

MiniDNS resolver: Fix exception when there is only a A or AAAA RR

W/System.err: java.lang.IllegalStateException: Can not perform operation because the DNS resolution was unsuccessful
W/System.err:     at de.measite.minidns.hla.ResolverResult.throwIseIfErrorResponse(ResolverResult.ja va:113)
W/System.err:     at de.measite.minidns.hla.ResolverResult.getAnswers(ResolverResult.java:56)
W/System.err:     at org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver.lookupHostAddress0(Mini DnsResolver.java:130)
W/System.err:     at org.jivesoftware.smack.util.dns.DNSResolver.lookupHostAddress(DNSResolver.java: 52)
W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.populateHostAddresses(AbstractXMP PConnection.java:612)
W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:555)
W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:885)
W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:374)
W/System.err:     at com.example.bosleo.chatapp.ChatConnection.connect(ChatConnection.java:147)
W/System.err:     at com.example.bosleo.chatapp.ChatConnectionService.initConnection(ChatConnectionS ervice.java:82)
W/System.err:     at com.example.bosleo.chatapp.ChatConnectionService.access$100(ChatConnectionServi ce.java:20)
W/System.err:     at com.example.bosleo.chatapp.ChatConnectionService$1.run(ChatConnectionService.ja va:105)
W/System.err:     at java.lang.Thread.run(Thread.java:818)
W/System.err: Caused by: de.measite.minidns.hla.ResolutionUnsuccessfulException: Asking for 192.168.2.128. IN AAAA yielded an error response NX_DOMAIN
W/System.err:     at de.measite.minidns.hla.ResolverResult.getResolutionUnsuccessfulException(Resolv erResult.java:89)
W/System.err:     at de.measite.minidns.hla.ResolverResult.throwIseIfErrorResponse(ResolverResult.ja va:111)
W/System.err: ... 12 more
This commit is contained in:
Florian Schmaus 2017-01-05 09:29:31 +01:00
parent e9bbe9a475
commit b343b499b5

View file

@ -20,8 +20,10 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.jivesoftware.smack.ConnectionConfiguration.DnssecMode;
import org.jivesoftware.smack.initializer.SmackInitializer;
@ -126,10 +128,28 @@ public class MiniDnsResolver extends DNSResolver implements SmackInitializer {
return null;
}
List<InetAddress> inetAddresses = new ArrayList<>(aResult.getAnswers().size()
+ aaaaResult.getAnswers().size());
// TODO: Use ResolverResult.getAnswersOrEmptySet() once we updated MiniDNS.
Set<A> aResults;
if (aResult.wasSuccessful()) {
aResults = aResult.getAnswers();
}
else {
aResults = Collections.emptySet();
}
for (A a : aResult.getAnswers()) {
// TODO: Use ResolverResult.getAnswersOrEmptySet() once we updated MiniDNS.
Set<AAAA> aaaaResults;
if (aaaaResult.wasSuccessful()) {
aaaaResults = aaaaResult.getAnswers();
}
else {
aaaaResults = Collections.emptySet();
}
List<InetAddress> inetAddresses = new ArrayList<>(aResults.size()
+ aaaaResults.size());
for (A a : aResults) {
InetAddress inetAddress;
try {
inetAddress = InetAddress.getByAddress(a.getIp());
@ -139,7 +159,7 @@ public class MiniDnsResolver extends DNSResolver implements SmackInitializer {
}
inetAddresses.add(inetAddress);
}
for (AAAA aaaa : aaaaResult.getAnswers()) {
for (AAAA aaaa : aaaaResults) {
InetAddress inetAddress;
try {
inetAddress = InetAddress.getByAddress(name, aaaa.getIp());