From b837029c1c8b0f56d95c37f7d150c7c9b4daec1a Mon Sep 17 00:00:00 2001 From: David Caruana Date: Thu, 13 Jul 2006 10:42:46 +0000 Subject: [PATCH] Fix AR-730 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3317 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/jcr/session/SessionImpl.java | 26 +++++++++++++------ .../alfresco/jcr/session/SessionImplTest.java | 26 ++++++++++++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/source/java/org/alfresco/jcr/session/SessionImpl.java b/source/java/org/alfresco/jcr/session/SessionImpl.java index b772e02d6a..ef4dd0d3f8 100644 --- a/source/java/org/alfresco/jcr/session/SessionImpl.java +++ b/source/java/org/alfresco/jcr/session/SessionImpl.java @@ -645,19 +645,29 @@ public class SessionImpl implements Session if (isLive()) { // invalidate authentication - getRepositoryImpl().getServiceRegistry().getAuthenticationService().invalidateTicket(getTicket()); - ticket = null; - - // clean up resources try { - sessionIsolation.rollback(); + try + { + getRepositoryImpl().getServiceRegistry().getAuthenticationService().invalidateTicket(getTicket()); + } + finally + { + try + { + sessionIsolation.rollback(); + } + catch(RepositoryException e) + { + // continue execution and force logout + } + } } - catch(RepositoryException e) + finally { - // force logout + ticket = null; + repository.deregisterSession(); } - repository.deregisterSession(); } } diff --git a/source/java/org/alfresco/jcr/session/SessionImplTest.java b/source/java/org/alfresco/jcr/session/SessionImplTest.java index 749bf13f3f..c0ea777968 100644 --- a/source/java/org/alfresco/jcr/session/SessionImplTest.java +++ b/source/java/org/alfresco/jcr/session/SessionImplTest.java @@ -94,5 +94,29 @@ public class SessionImplTest extends BaseJCRTest assertFalse(isLive); } + + public void testSessionThread() + { + SimpleCredentials superuser = new SimpleCredentials("superuser", "".toCharArray()); + try + { + Session anotherSession = repository.login(superuser, getWorkspace()); + fail("Exception not thrown when establishing two sessions on same thread"); + } + catch(RepositoryException e) + { + // successful - multiple sessions on one thread caught + } + superuserSession.logout(); + try + { + Session anotherSession = repository.login(superuser, getWorkspace()); + anotherSession.logout(); + } + catch(RepositoryException e) + { + fail("Exception thrown when it shouldn't of been."); + } + } + } -