Ensure we always release the AddressEnvelope when doing DNS queries.

This commit is contained in:
nathan 2018-03-26 23:08:13 +02:00
parent bac7df8b9a
commit e44ee694c7

View File

@ -342,6 +342,15 @@ class DnsNameResolverContext<T> {
if (promise.isDone() || future.isCancelled()) {
queryLifecycleObserver.queryCancelled(allowedQueries);
// Check if we need to release the envelope itself. If the query was cancelled the getNow() will
// return null as well as the Future will be failed with a CancellationException.
DnsResponse result = future.getNow();
if (result != null) {
result.release();
}
return;
}