lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1561499 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/solrj/ solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
Date Sun, 26 Jan 2014 14:53:30 GMT
Author: markrmiller
Date: Sun Jan 26 14:53:30 2014
New Revision: 1561499

URL: http://svn.apache.org/r1561499
Log:
SOLR-5577: Harden leaking Timer thread.

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java?rev=1561499&r1=1561498&r2=1561499&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
Sun Jan 26 14:53:30 2014
@@ -72,8 +72,8 @@ public class ConnectionManager implement
   private synchronized void disconnected() {
     cancelTimer();
     if (!isClosed) {
-      disconnectedTimer = new Timer(true);
-      disconnectedTimer.schedule(new TimerTask() {
+      Timer newDcTimer = new Timer(true);
+      newDcTimer.schedule(new TimerTask() {
         
         @Override
         public void run() {
@@ -84,7 +84,16 @@ public class ConnectionManager implement
       if (isClosed) {
         // we might have closed after getting by isClosed
         // and before starting the new timer
-        cancelTimer();
+        newDcTimer.cancel();
+      } else {
+        disconnectedTimer = newDcTimer;
+        if (isClosed) {
+          // now deal with we may have been closed after getting
+          // by isClosed but before setting disconnectedTimer -
+          // if close happens after isClosed check this time, it 
+          // will handle stopping the timer
+          cancelTimer();
+        }
       }
     }
     connected = false;
@@ -196,7 +205,7 @@ public class ConnectionManager implement
   }
   
   // we use a volatile rather than sync
-  // to avoid deadlock on shutdown
+  // to avoid possible deadlock on shutdown
   public void close() {
     this.isClosed = true;
     this.likelyExpired = true;



Mime
View raw message