浏览代码

Log exception thrown in ScriptEngineService.scriptRemoved

Guava would swallow the exception and log it itself if we bubbled it up,
so we catch and log it ourselves to use our logging infrastructure.
Lee Hinman 11 年之前
父节点
当前提交
9e7fba9a7b
共有 1 个文件被更改,包括 3 次插入7 次删除
  1. 3 7
      src/main/java/org/elasticsearch/script/ScriptService.java

+ 3 - 7
src/main/java/org/elasticsearch/script/ScriptService.java

@@ -27,7 +27,6 @@ import com.google.common.cache.RemovalNotification;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap;
 import org.elasticsearch.ElasticsearchIllegalArgumentException;
 import org.elasticsearch.ElasticsearchIllegalArgumentException;
 import org.elasticsearch.ElasticsearchIllegalStateException;
 import org.elasticsearch.ElasticsearchIllegalStateException;
-import org.elasticsearch.ExceptionsHelper;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.delete.DeleteRequest;
 import org.elasticsearch.action.delete.DeleteRequest;
 import org.elasticsearch.action.delete.DeleteResponse;
 import org.elasticsearch.action.delete.DeleteResponse;
@@ -67,15 +66,12 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.InputStreamReader;
-import java.util.List;
 import java.util.Locale;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
-import static com.google.common.collect.Lists.newArrayList;
-
 /**
 /**
  *
  *
  */
  */
@@ -502,15 +498,15 @@ public class ScriptService extends AbstractComponent {
             if (logger.isDebugEnabled()) {
             if (logger.isDebugEnabled()) {
                 logger.debug("notifying script services of script removal due to: [{}]", notification.getCause());
                 logger.debug("notifying script services of script removal due to: [{}]", notification.getCause());
             }
             }
-            List<Exception> errors = newArrayList();
             for (ScriptEngineService service : scriptEngines.values()) {
             for (ScriptEngineService service : scriptEngines.values()) {
                 try {
                 try {
                     service.scriptRemoved(notification.getValue());
                     service.scriptRemoved(notification.getValue());
                 } catch (Exception e) {
                 } catch (Exception e) {
-                    errors.add(e);
+                    logger.warn("exception calling script removal listener for script service", e);
+                    // We don't rethrow because Guava would just catch the
+                    // exception and log it, which we have already done
                 }
                 }
             }
             }
-            ExceptionsHelper.maybeThrowRuntimeAndSuppress(errors);
         }
         }
     }
     }