Fix another resource leak in DnsNameResolver

- Fix a bug in cache expiration task; wrong object was being released
- Added more sanity checks when caching an entry