Author: julien_viet
Date: 2009-12-02 08:53:44 -0500 (Wed, 02 Dec 2009)
New Revision: 908
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/LocalContext.java
portal/trunk/component/common/src/test/java/org/exoplatform/commons/chromattic/ChromatticIntegrationTestCase.java
Log:
fix NPE when a local context is created but no session is opened
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/LocalContext.java
===================================================================
---
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/LocalContext.java 2009-12-02
12:32:18 UTC (rev 907)
+++
portal/trunk/component/common/src/main/java/org/exoplatform/commons/chromattic/LocalContext.java 2009-12-02
13:53:44 UTC (rev 908)
@@ -28,7 +28,7 @@
{
/** The related JCR session. */
- Session jcrSession;
+ private Session jcrSession;
public LocalContext(ChromatticLifeCycle configurator)
{
@@ -49,7 +49,10 @@
}
finally
{
- jcrSession.logout();
+ if (jcrSession != null)
+ {
+ jcrSession.logout();
+ }
}
}
}
Modified:
portal/trunk/component/common/src/test/java/org/exoplatform/commons/chromattic/ChromatticIntegrationTestCase.java
===================================================================
---
portal/trunk/component/common/src/test/java/org/exoplatform/commons/chromattic/ChromatticIntegrationTestCase.java 2009-12-02
12:32:18 UTC (rev 907)
+++
portal/trunk/component/common/src/test/java/org/exoplatform/commons/chromattic/ChromatticIntegrationTestCase.java 2009-12-02
13:53:44 UTC (rev 908)
@@ -130,6 +130,12 @@
assertFalse(jcrSession.isLive());
}
+ public void testLocalRequestNoSessionAccess()
+ {
+ SessionContext context = configurator.openContext();
+ configurator.closeContext(context, false);
+ }
+
public void testGlobalRequest() throws Exception
{
Session jcrSession;
Show replies by date