Ensure we release the previous retained AddressedEnvelope when we fail to notify the promise.
Motivation: We need to ensure we release the AddressedEnvelope if we fail to notify the future (as it may be notified before because of an timeout). Otherwise we may leak. Modifications: Call release() if we fail to notify the future. Result: No more memory leak on notify failure.
This commit is contained in:
parent
14b902fced
commit
3462a86a3a
@ -191,7 +191,10 @@ final class DnsQueryContext {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AddressedEnvelope<DnsResponse, InetSocketAddress> castResponse =
|
AddressedEnvelope<DnsResponse, InetSocketAddress> castResponse =
|
||||||
(AddressedEnvelope<DnsResponse, InetSocketAddress>) envelope.retain();
|
(AddressedEnvelope<DnsResponse, InetSocketAddress>) envelope.retain();
|
||||||
promise.setSuccess(castResponse);
|
if (!promise.trySuccess(castResponse)) {
|
||||||
|
// We failed to notify the promise as it was failed before, thus we need to release the envelope
|
||||||
|
envelope.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user