From bf8574833a4803926958700e80a1a292a23b365e Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 2 Aug 2013 12:14:17 +1200 Subject: [PATCH] Remove Thread UncaughtExceptionHandler as part of fix for pull/44 @Transactional not rolling back for uncaught RuntimeException - This change is not required for 44 but is nice cleanup as UncaughtExceptionHandler is no used. --- .../avaje/ebeaninternal/api/ScopeTrans.java | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java index 9cb8e9522..42a86c48f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java @@ -1,6 +1,5 @@ package com.avaje.ebeaninternal.api; -import java.lang.Thread.UncaughtExceptionHandler; import java.util.ArrayList; import com.avaje.ebean.TxScope; @@ -45,9 +44,6 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { */ private final ArrayList> rollbackFor; - - private final UncaughtExceptionHandler originalUncaughtHandler; - /** * Flag set when a rollback has occurred. */ @@ -65,11 +61,6 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { this.noRollbackFor = txScope.getNoRollbackFor(); this.rollbackFor = txScope.getRollbackFor(); - - Thread t = Thread.currentThread(); - originalUncaughtHandler = t.getUncaughtExceptionHandler(); - - t.setUncaughtExceptionHandler(this); } /** @@ -81,13 +72,8 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { // rollback transaction if required caughtThrowable(e); - // reinstate suspended transaction and - // original uncaughtExceptionHandler if required + // reinstate suspended transaction onFinally(); - - if (originalUncaughtHandler != null){ - originalUncaughtHandler.uncaughtException(thread, e); - } } /** @@ -110,11 +96,7 @@ public class ScopeTrans implements Thread.UncaughtExceptionHandler { * Also reinstate the suspended transaction if there was one. */ public void onFinally() { - try { - if (originalUncaughtHandler != null){ - Thread.currentThread().setUncaughtExceptionHandler(originalUncaughtHandler); - } - + try { if (!rolledBack && created) { transaction.commit(); }