diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/JmDNSFactory.java b/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/JmDNSFactory.java index 08f61bca29..6913693201 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/JmDNSFactory.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/JmDNSFactory.java @@ -46,7 +46,7 @@ public final class JmDNSFactory { return tracker.jmDNS; } - static synchronized boolean onClose(InetAddress address, JmDNS dns) { + static synchronized boolean onClose(InetAddress address) { UsageTracker tracker = registry.get(address); if (tracker != null) { if (tracker.count.decrementAndGet() == 0) { diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/ZeroconfDiscoveryAgent.java b/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/ZeroconfDiscoveryAgent.java index 77fc9f3f9c..714ca39b14 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/ZeroconfDiscoveryAgent.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/discovery/zeroconf/ZeroconfDiscoveryAgent.java @@ -92,7 +92,9 @@ public class ZeroconfDiscoveryAgent implements DiscoveryAgent, ServiceListener { Thread thread = new Thread() { public void run() { try { - JmDNSFactory.onClose(getLocalAddress(), closeTarget); + if (JmDNSFactory.onClose(getLocalAddress())) { + closeTarget.close(); + }; } catch (IOException e) { LOG.debug("Error closing JmDNS " + getLocalhost() + ". This exception will be ignored.", e); }