From d726d9c75a4bb178c9f7e1cba63a0fa406ca1eca Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 7 Aug 2015 10:03:18 -0500 Subject: [PATCH] IDEMPIERE-2756 Background threads losing context when user log out --- org.adempiere.base/src/org/compiere/model/PO.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 83bb9c1e3d..430dd1fd48 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -1989,6 +1989,7 @@ public abstract class PO */ public boolean save() { + checkValidContext(); CLogger.resetLast(); boolean newRecord = is_new(); // save locally as load resets if (!newRecord && !is_Changed()) @@ -3107,6 +3108,7 @@ public abstract class PO */ public boolean delete (boolean force) { + checkValidContext(); CLogger.resetLast(); if (is_new()) return true; @@ -4670,4 +4672,10 @@ public abstract class PO log.saveError(msg, info); } } + + private void checkValidContext() { + if (getCtx().size() == 0) + throw new AdempiereException("Context lost"); + } + } // PO