From c6bf87ef057ef92a53696e064ddbc7212f01ba90 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 14 Oct 2015 20:19:13 -0500 Subject: [PATCH] IDEMPIERE-2756 Background threads losing context when user log out - fix validation / integrate fix from hengsin: error when user close the browser tab while a report/process is still running --- .../src/org/compiere/process/SvrProcess.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/process/SvrProcess.java b/org.adempiere.base/src/org/compiere/process/SvrProcess.java index 67ca51f844..deb3c2430f 100644 --- a/org.adempiere.base/src/org/compiere/process/SvrProcess.java +++ b/org.adempiere.base/src/org/compiere/process/SvrProcess.java @@ -563,8 +563,13 @@ public abstract class SvrProcess implements ProcessCall */ private void unlock () { + boolean noContext = Env.getCtx().isEmpty() && Env.getCtx().getProperty("#AD_Client_ID") == null; try { + //save logging info even if context is lost + if (noContext) + Env.getCtx().put("#AD_Client_ID", m_pi.getAD_Client_ID()); + MPInstance mpi = new MPInstance (getCtx(), m_pi.getAD_PInstance_ID(), null); if (mpi.get_ID() == 0) { @@ -583,6 +588,11 @@ public abstract class SvrProcess implements ProcessCall { log.severe("unlock() - " + e.getLocalizedMessage()); } + finally + { + if (noContext) + Env.getCtx().remove("#AD_Client_ID"); + } } // unlock /**