You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2015/04/24 15:45:33 UTC
[6/9] storm git commit: UncaughtExceptionHandler must not ignore any
errors
UncaughtExceptionHandler must not ignore any errors
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/85b87d92
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/85b87d92
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/85b87d92
Branch: refs/heads/master
Commit: 85b87d92219a10d458b78bdaab64cafae9d22b5a
Parents: 5d6b62b
Author: Kishor Patil <kp...@yahoo-inc.com>
Authored: Wed Apr 8 22:37:05 2015 +0000
Committer: Kishor Patil <kp...@yahoo-inc.com>
Committed: Wed Apr 8 22:37:05 2015 +0000
----------------------------------------------------------------------
storm-core/src/clj/backtype/storm/util.clj | 7 +++++-
.../src/jvm/backtype/storm/utils/Utils.java | 23 +++++++++++++-------
2 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/85b87d92/storm-core/src/clj/backtype/storm/util.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/util.clj b/storm-core/src/clj/backtype/storm/util.clj
index b1a9b2e..41b900b 100644
--- a/storm-core/src/clj/backtype/storm/util.clj
+++ b/storm-core/src/clj/backtype/storm/util.clj
@@ -1038,5 +1038,10 @@
(Thread/setDefaultUncaughtExceptionHandler
(proxy [Thread$UncaughtExceptionHandler] []
(uncaughtException [thread thrown]
- (Utils/handleUncaughtException thrown)))))
+ (try
+ (Utils/handleUncaughtException thrown)
+ (catch Error err
+ (do
+ (log-error err "Received error in main thread.. terminating server...")
+ (.exit (Runtime/getRuntime) -2))))))))
http://git-wip-us.apache.org/repos/asf/storm/blob/85b87d92/storm-core/src/jvm/backtype/storm/utils/Utils.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/utils/Utils.java b/storm-core/src/jvm/backtype/storm/utils/Utils.java
index 94f9141..47eba55 100644
--- a/storm-core/src/jvm/backtype/storm/utils/Utils.java
+++ b/storm-core/src/jvm/backtype/storm/utils/Utils.java
@@ -534,15 +534,22 @@ public class Utils {
return delegate;
}
- public static void handleUncaughtException(Throwable t) {
- if(t!= null && t instanceof OutOfMemoryError) {
- try {
- System.err.println("Halting due to Out Of Memory Error..." + Thread.currentThread().getName());
- } catch (Throwable err) {
- //Again we done want to exit because of logging issues.
- }
- Runtime.getRuntime().halt(-1);
+ public static void handleUncaughtException(Throwable t) {
+ if (t != null && t instanceof Error) {
+ if (t instanceof OutOfMemoryError) {
+ try {
+ System.err.println("Halting due to Out Of Memory Error..." + Thread.currentThread().getName());
+ } catch (Throwable err) {
+ //Again we don't want to exit because of logging issues.
+ }
+ Runtime.getRuntime().halt(-1);
+ } else {
+ //Running in daemon mode, we would pass Error to calling thread.
+ throw (Error) t;
}
+ } else {
+ LOG.error("Thread threw an Exception.", t);
}
+ }
}