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."); + } + } + } -