From ebfbea1b9a3de8c19be7c459856a9308d5cc836d Mon Sep 17 00:00:00 2001 From: Andrew Zeneski Date: Fri, 21 Sep 2007 21:03:03 +0000 Subject: [PATCH] uses nested trys git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@578273 13f79535-47bb-0310-9956-ffa450edef68 --- .../service/semaphore/ServiceSemaphore.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java b/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java index 4bbd9adf3c..5ffc5d8089 100644 --- a/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java +++ b/framework/service/src/org/ofbiz/service/semaphore/ServiceSemaphore.java @@ -7,10 +7,13 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.transaction.GenericTransactionException; +import org.ofbiz.entity.transaction.GenericXaResource; import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.service.ModelService; import javax.transaction.Transaction; +import javax.transaction.xa.Xid; +import javax.transaction.xa.XAException; import java.sql.Timestamp; import java.util.Map; @@ -146,24 +149,25 @@ public class ServiceSemaphore { Debug.logError(e, module); isError = true; throw new SemaphoreFailException("Cannot obtain unique transaction for semaphore logging"); + } finally { + if (isError) { + try { + TransactionUtil.rollback(beganTx, "ServiceSemaphore: dbWrite()", new Exception()); + } catch (GenericTransactionException e) { + Debug.logError(e, module); + } + } + if (!isError && beganTx) { + try { + TransactionUtil.commit(beganTx); + } catch (GenericTransactionException e) { + Debug.logError(e, module); + } + } } } catch (GenericTransactionException e) { Debug.logError(e, module); - } finally { - if (isError) { - try { - TransactionUtil.rollback(beganTx, "ServiceSemaphore: dbWrite()", new Exception()); - } catch (GenericTransactionException e) { - Debug.logError(e, module); - } - } - if (!isError && beganTx) { - try { - TransactionUtil.commit(beganTx); - } catch (GenericTransactionException e) { - Debug.logError(e, module); - } - } + } finally { if (parent != null) { try { TransactionUtil.resume(parent);