From 0eb6e9bf74fa55eff9aa9a3e9a147ec3e34e94d6 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 19 May 2017 11:13:20 +0200 Subject: [PATCH] Integrating a generic improvement on Env class from Heng Sin - fixing an issue that could lead to context lost --- org.adempiere.base/src/org/compiere/util/Env.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/util/Env.java b/org.adempiere.base/src/org/compiere/util/Env.java index b28f081e71..3458c86fa9 100644 --- a/org.adempiere.base/src/org/compiere/util/Env.java +++ b/org.adempiere.base/src/org/compiere/util/Env.java @@ -48,6 +48,7 @@ import javax.swing.JFrame; import org.adempiere.base.Core; import org.adempiere.base.IResourceFinder; import org.adempiere.util.IProcessUI; +import org.adempiere.util.ServerContext; import org.adempiere.util.ServerContextProvider; import org.compiere.Adempiere; import org.compiere.db.CConnection; @@ -244,6 +245,11 @@ public final class Env { if (ctx == null) throw new IllegalArgumentException ("Require Context"); + + //nothing to do if ctx is already the current context + if (ServerContext.getCurrentInstance() == ctx) + return; + getCtx().clear(); getCtx().putAll(ctx); } // setCtx