From 74e8226ab0fefebc46b798e45cd5211f3bf98513 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 17 Oct 2023 03:42:26 +0200 Subject: [PATCH] IDEMPIERE-4346 [Allocation Reset] - Don't close trx when exception is throw (#2059) --- .../org/compiere/process/AllocationReset.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java b/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java index 9f0a64d176..a9bdcfff36 100644 --- a/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java +++ b/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java @@ -111,12 +111,15 @@ public class AllocationReset extends SvrProcess if (p_C_AllocationHdr_ID != 0) { - MAllocationHdr hdr = new MAllocationHdr(getCtx(), p_C_AllocationHdr_ID, m_trx.getTrxName()); - if (delete(hdr)) - count++; - else - throw new AdempiereException("Cannot delete"); - m_trx.close(); + try { + MAllocationHdr hdr = new MAllocationHdr(getCtx(), p_C_AllocationHdr_ID, m_trx.getTrxName()); + if (delete(hdr)) + count++; + else + throw new AdempiereException("Cannot delete"); + } finally { + m_trx.close(); + } StringBuilder msgreturn = new StringBuilder("@Deleted@ #").append(count); return msgreturn.toString(); } @@ -176,8 +179,8 @@ public class AllocationReset extends SvrProcess { DB.close(rs, pstmt); rs = null; pstmt = null; + m_trx.close(); } - m_trx.close(); StringBuilder msgreturn = new StringBuilder("@Deleted@ #").append(count); return msgreturn.toString(); } // doIt