lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1175651 - /lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java
Date Mon, 26 Sep 2011 03:28:56 GMT
Author: markrmiller
Date: Mon Sep 26 03:28:55 2011
New Revision: 1175651

URL: http://svn.apache.org/viewvc?rev=1175651&view=rev
Log:
SOLR-2793: Somtimes you must dec ref twice, and add fix to the other submit calls

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1175651&r1=1175650&r2=1175651&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java Mon Sep 26 03:28:55
2011
@@ -1193,52 +1193,85 @@ public final class SolrCore implements S
       // warm the new searcher based on the current searcher.
       // should this go before the other event handlers or after?
       if (currSearcher != null) {
-        future = searcherExecutor.submit(
-                new Callable() {
-                  public Object call() throws Exception {
-                    try {
-                      newSearcher.warm(currSearcher);
-                    } catch (Throwable e) {
-                      SolrException.logOnce(log,null,e);
+        try {
+          future = searcherExecutor.submit(
+                  new Callable() {
+                    public Object call() throws Exception {
+                      try {
+                        newSearcher.warm(currSearcher);
+                      } catch (Throwable e) {
+                        SolrException.logOnce(log,null,e);
+                      }
+                      return null;
                     }
-                    return null;
                   }
-                }
-        );
+          );
+        } catch(Exception e) {
+          // if submit fails, newSearchHolder does not get decref'd
+          if (newSearchHolder != null) {
+            newSearchHolder.decref();
+            if (returnSearcher) {
+              newSearchHolder.decref();
+            }
+          }
+          throw e;
+        }
       }
       
       if (currSearcher==null && firstSearcherListeners.size() > 0) {
-        future = searcherExecutor.submit(
-                new Callable() {
-                  public Object call() throws Exception {
-                    try {
-                      for (SolrEventListener listener : firstSearcherListeners) {
-                        listener.newSearcher(newSearcher,null);
+        try {
+          future = searcherExecutor.submit(
+                  new Callable() {
+                    public Object call() throws Exception {
+                      try {
+                        for (SolrEventListener listener : firstSearcherListeners) {
+                          listener.newSearcher(newSearcher,null);
+                        }
+                      } catch (Throwable e) {
+                        SolrException.logOnce(log,null,e);
                       }
-                    } catch (Throwable e) {
-                      SolrException.logOnce(log,null,e);
+                      return null;
                     }
-                    return null;
                   }
-                }
-        );
+          );
+        } catch(Exception e) {
+          // if submit fails, newSearchHolder does not get decref'd
+          if (newSearchHolder != null) {
+            newSearchHolder.decref();
+            if (returnSearcher) {
+              newSearchHolder.decref();
+            }
+          }
+          throw e;
+        }
       }
 
       if (currSearcher!=null && newSearcherListeners.size() > 0) {
-        future = searcherExecutor.submit(
-                new Callable() {
-                  public Object call() throws Exception {
-                    try {
-                      for (SolrEventListener listener : newSearcherListeners) {
-                        listener.newSearcher(newSearcher, currSearcher);
+        try {
+          future = searcherExecutor.submit(
+                  new Callable() {
+                    public Object call() throws Exception {
+                      try {
+                        for (SolrEventListener listener : newSearcherListeners) {
+                          listener.newSearcher(newSearcher, currSearcher);
+                        }
+                      } catch (Throwable e) {
+                        SolrException.logOnce(log,null,e);
                       }
-                    } catch (Throwable e) {
-                      SolrException.logOnce(log,null,e);
+                      return null;
                     }
-                    return null;
                   }
-                }
-        );
+          );
+      } catch(Exception e) {
+        // if submit fails, newSearchHolder does not get decref'd
+        if (newSearchHolder != null) {
+          newSearchHolder.decref();
+          if (returnSearcher) {
+            newSearchHolder.decref();
+          }
+        }
+        throw e;
+      }
       }
 
       // WARNING: this code assumes a single threaded executor (that all tasks
@@ -1268,7 +1301,12 @@ public final class SolrCore implements S
           );
         } catch(Exception e) {
           // if submit fails, newSearchHolder does not get decref'd
-          if (returnSearcher && newSearchHolder != null) newSearchHolder.decref();
+          if (newSearchHolder != null) {
+            newSearchHolder.decref();
+            if (returnSearcher) {
+              newSearchHolder.decref();
+            }
+          }
           throw e;
         }
       }



Mime
View raw message