mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Move DnsNameResolver creation into try-catch block.
This commit is contained in:
parent
bb12069f95
commit
ead6afae39
1 changed files with 10 additions and 3 deletions
|
@ -146,11 +146,14 @@ public class TcpClientSession extends TcpSession {
|
|||
System.out.println("[PacketLib] Attempting SRV lookup for \"" + name + "\".");
|
||||
}
|
||||
|
||||
DnsNameResolver resolver = null;
|
||||
AddressedEnvelope<DnsResponse, InetSocketAddress> envelope = null;
|
||||
try(DnsNameResolver resolver = new DnsNameResolverBuilder(this.group.next())
|
||||
try {
|
||||
resolver = new DnsNameResolverBuilder(this.group.next())
|
||||
.channelType(NioDatagramChannel.class)
|
||||
.build()) {
|
||||
.build();
|
||||
envelope = resolver.query(new DefaultDnsQuestion(name, DnsRecordType.SRV)).get();
|
||||
|
||||
DnsResponse response = envelope.content();
|
||||
if(response.count(DnsSection.ANSWER) > 0) {
|
||||
DefaultDnsRawRecord record = response.recordAt(DnsSection.ANSWER, 0);
|
||||
|
@ -185,6 +188,10 @@ public class TcpClientSession extends TcpSession {
|
|||
if(envelope != null) {
|
||||
envelope.release();
|
||||
}
|
||||
|
||||
if(resolver != null) {
|
||||
resolver.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue