Author: pferraro
Date: 2009-04-23 14:56:25 -0400 (Thu, 23 Apr 2009)
New Revision: 2405
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/advertise/impl/AdvertiseListenerImpl.java
Log:
[MODCLUSTER-73] Wait for worker to die in stop() to prevent NullPointerException if worker
tries to use socket after destroy()
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/advertise/impl/AdvertiseListenerImpl.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/advertise/impl/AdvertiseListenerImpl.java 2009-04-23
10:07:06 UTC (rev 2404)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/advertise/impl/AdvertiseListenerImpl.java 2009-04-23
18:56:25 UTC (rev 2405)
@@ -71,7 +71,7 @@
InetAddress groupAddress = null;
private MulticastSocketFactory socketFactory;
- MulticastSocket socket;
+ volatile MulticastSocket socket;
private boolean daemon = true;
@@ -309,7 +309,20 @@
if (this.workerThread != null)
{
this.workerThread.interrupt();
+
+ // In case worker is stuck on socket.receive(...)
this.interruptDatagramReader();
+
+ try
+ {
+ // Wait for worker to complete
+ this.workerThread.join();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+
this.workerThread = null;
this.listening = false;