From d7ea4de2f525de9f6a82598273a29161f677211f Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Tue, 9 Oct 2007 15:48:30 +0000 Subject: [PATCH] BF [ 1810182 ] Session lost after cache reset http://sourceforge.net/tracker/index.php?func=detail&aid=1810182&group_id=176962&atid=879332 --- base/src/org/compiere/model/MSession.java | 13 ++++++++++ extend/build.xml | 1 + extend/src/test/functional/MSessionTest.java | 25 ++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 extend/src/test/functional/MSessionTest.java diff --git a/base/src/org/compiere/model/MSession.java b/base/src/org/compiere/model/MSession.java index f0303ba5cf..7d7ec260d0 100644 --- a/base/src/org/compiere/model/MSession.java +++ b/base/src/org/compiere/model/MSession.java @@ -28,6 +28,9 @@ import org.compiere.util.*; * * @author Jorg Janke * @version $Id: MSession.java,v 1.3 2006/07/30 00:58:05 jjanke Exp $ + * + * @author Teo Sarca, SC ARHIPAC SERVICE SRL + *
  • BF [ 1810182 ] Session lost after cache reset */ public class MSession extends X_AD_Session { @@ -43,6 +46,16 @@ public class MSession extends X_AD_Session MSession session = null; if (AD_Session_ID > 0) session = (MSession)s_sessions.get(new Integer(AD_Session_ID)); + // Try to load + if (session == null && AD_Session_ID > 0) + { + session = new MSession(ctx, AD_Session_ID, null); + if (session.get_ID() != AD_Session_ID) { + Env.setContext (ctx, "#AD_Session_ID", AD_Session_ID); + s_sessions.put(AD_Session_ID, session); + } + } + // Create New if (session == null && createNew) { session = new MSession (ctx, null); // local session diff --git a/extend/build.xml b/extend/build.xml index 03a3a2a274..26c9edf5d0 100644 --- a/extend/build.xml +++ b/extend/build.xml @@ -96,6 +96,7 @@ + diff --git a/extend/src/test/functional/MSessionTest.java b/extend/src/test/functional/MSessionTest.java new file mode 100644 index 0000000000..b4f6af8144 --- /dev/null +++ b/extend/src/test/functional/MSessionTest.java @@ -0,0 +1,25 @@ +/** + * + */ +package test.functional; + +import org.compiere.model.MSession; +import org.compiere.util.Env; + +import test.AdempiereTestCase; + +/** + * Test MSession class + * @author Teo Sarca, SC ARHIPAC SERVICE SRL + */ +public class MSessionTest extends AdempiereTestCase { + + /** + * Test - BF [ 1810182 ] Session lost after cache reset + */ + public void testBF1810182 () { + assertNotNull("Session not found, should not fail here", MSession.get(getCtx(), true)); + Env.reset(false); + assertNotNull("Session not found after cache reset", MSession.get(getCtx(), false)); + } +}