lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1388133 - /lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java
Date Thu, 20 Sep 2012 17:44:41 GMT
Author: uschindler
Date: Thu Sep 20 17:44:41 2012
New Revision: 1388133

URL: http://svn.apache.org/viewvc?rev=1388133&view=rev
Log:
SOLR-3733: More improvements: don't hang on the died threads until forever...

Modified:
    lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java

Modified: lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java?rev=1388133&r1=1388132&r2=1388133&view=diff
==============================================================================
--- lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java
(original)
+++ lucene/dev/branches/solr3733/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZooKeeper.java
Thu Sep 20 17:44:41 2012
@@ -21,8 +21,8 @@ import java.io.IOException;
 import java.lang.reflect.Field;
 import java.nio.channels.SelectableChannel;
 import java.nio.channels.SelectionKey;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
 
 import org.apache.zookeeper.ClientCnxn;
 import org.apache.zookeeper.Watcher;
@@ -30,7 +30,7 @@ import org.apache.zookeeper.ZooKeeper;
 
 // we use this class to expose nasty stuff for tests
 public class SolrZooKeeper extends ZooKeeper {
-  List<Thread> spawnedThreads = new CopyOnWriteArrayList<Thread>();
+  Set<Thread> spawnedThreads = new CopyOnWriteArraySet<Thread>();
   
   // for test debug
   //static Map<SolrZooKeeper,Exception> clients = new ConcurrentHashMap<SolrZooKeeper,Exception>();
@@ -61,7 +61,7 @@ public class SolrZooKeeper extends ZooKe
    * @param ms the number of milliseconds to pause.
    */
   public void pauseCnxn(final long ms) {
-    Thread t = new Thread() {
+    final Thread t = new Thread() {
       public void run() {
         try {
           synchronized (cnxn) {
@@ -72,11 +72,15 @@ public class SolrZooKeeper extends ZooKe
             }
             Thread.sleep(ms);
           }
-        } catch (InterruptedException e) {}
+        } catch (InterruptedException e) {
+          // ignore
+        } finally {
+          spawnedThreads.remove(this);
+        }
       }
     };
-    t.start();
     spawnedThreads.add(t);
+    t.start();
   }
 
   @Override



Mime
View raw message