Merge pull request #21 from ptgoetz/cluster-ids

WIP on configurable cluster names
diff --git a/src/main/java/com/google/code/gossip/manager/GossipManager.java b/src/main/java/com/google/code/gossip/manager/GossipManager.java
index ca88feb..b695fcc 100644
--- a/src/main/java/com/google/code/gossip/manager/GossipManager.java
+++ b/src/main/java/com/google/code/gossip/manager/GossipManager.java
@@ -188,8 +188,12 @@
   public void shutdown() {
     _gossipServiceRunning.set(false);
     _gossipThreadExecutor.shutdown();
-    passiveGossipThread.shutdown();
-    activeGossipThread.shutdown();
+    if (passiveGossipThread != null){
+      passiveGossipThread.shutdown();
+    }
+    if (activeGossipThread != null){
+      activeGossipThread.shutdown();
+    }
     try {
       boolean result = _gossipThreadExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS);
       if (!result){
diff --git a/src/main/java/com/google/code/gossip/manager/PassiveGossipThread.java b/src/main/java/com/google/code/gossip/manager/PassiveGossipThread.java
index bfb8732..5dcea09 100644
--- a/src/main/java/com/google/code/gossip/manager/PassiveGossipThread.java
+++ b/src/main/java/com/google/code/gossip/manager/PassiveGossipThread.java
@@ -67,7 +67,6 @@
       _cluster = _gossipManager.getMyself().getClusterName();
     } catch (SocketException ex) {
       GossipService.LOGGER.warn(ex);
-      _server = null;
       throw new RuntimeException(ex);
     }
     _keepRunning = new AtomicBoolean(true);
@@ -145,7 +144,9 @@
   }
 
   public void shutdown() {
+    try {
     _server.close();
+    } catch (RuntimeException ex){ }
   }
 
   /**