AMQ-4056 - ensure we do a close

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1404271 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2012-10-31 17:50:03 +00:00
parent 90beb3fb7d
commit 13270e4e74
2 changed files with 4 additions and 2 deletions

View File

@ -46,7 +46,7 @@ public final class JmDNSFactory {
return tracker.jmDNS; return tracker.jmDNS;
} }
static synchronized boolean onClose(InetAddress address, JmDNS dns) { static synchronized boolean onClose(InetAddress address) {
UsageTracker tracker = registry.get(address); UsageTracker tracker = registry.get(address);
if (tracker != null) { if (tracker != null) {
if (tracker.count.decrementAndGet() == 0) { if (tracker.count.decrementAndGet() == 0) {

View File

@ -92,7 +92,9 @@ public class ZeroconfDiscoveryAgent implements DiscoveryAgent, ServiceListener {
Thread thread = new Thread() { Thread thread = new Thread() {
public void run() { public void run() {
try { try {
JmDNSFactory.onClose(getLocalAddress(), closeTarget); if (JmDNSFactory.onClose(getLocalAddress())) {
closeTarget.close();
};
} catch (IOException e) { } catch (IOException e) {
LOG.debug("Error closing JmDNS " + getLocalhost() + ". This exception will be ignored.", e); LOG.debug("Error closing JmDNS " + getLocalhost() + ". This exception will be ignored.", e);
} }