Source:
<code>public User call() throws Exception { User currentUser = null; ClientSessionManager.ensureSessionCreated(); if (ClientSessionManager.isSessionValid()) { String userId = ClientSessionManager.getSession().getUserId(); if (SystemUser.BootStrap.getUserId().equals(userId)) { currentUser = BootStrapUser.getInstance(); } else { IUserToken currentUserToken = ClientSessionManager.getCurrentUserToken(); if (ClientSessionManager.isUserCreationRequired()) { duringCreateUser.set(true); <START> currentUser = writer.createUser(currentUserToken, "Populate current user"); <END> ClientSessionManager.clearUserCreationRequired(); duringCreateUser.set(false); } else { try { currentUser = getUser(currentUserToken); } catch (UserNotInDatabase ex) { if (isGuestAuthenticationAllowed.compareAndSet(true, false)) { ClientSessionManager.authenticateAsGuest(); currentUser = getUser(SystemUser.Guest); } } } } } else { if (isGuestAuthenticationAllowed.compareAndSet(true, false)) { ClientSessionManager.authenticateAsGuest(); currentUser = getUser(SystemUser.Guest); } } if (currentUser == null) { throw new OseeStateException("Setting current user to null."); } else { if (currentUser.getName().equals(SystemUser.Guest.getName())) { if (isGuestNotificationAllowed.compareAndSet(true, false)) { OseeLog.log(Activator.class, Level.INFO, "You are logged into OSEE as \"Guest\". If this is unexpected notify your OSEE admin"); } } } if (ClientSessionManager.isSessionValid()) { AccessControlEvent event = new AccessControlEvent(); event.setEventType(AccessControlEventType.UserAuthenticated); OseeEventManager.kickAccessControlArtifactsEvent(this, event); } return currentUser; }</code><technical_language>if writer.createUser method throws exception? this block in "try...finally" prevent class stuck duringCreateUser set true</technical_language>

Target:
public User call() throws Exception { User currentUser = null; ClientSessionManager.ensureSessionCreated(); if (ClientSessionManager.isSessionValid()) { String userId = ClientSessionManager.getSession().getUserId(); if (SystemUser.BootStrap.getUserId().equals(userId)) { currentUser = BootStrapUser.getInstance(); } else { IUserToken currentUserToken = ClientSessionManager.getCurrentUserToken(); if (ClientSessionManager.isUserCreationRequired()) { try { duringCreateUser.set(true); currentUser = writer.createUser(currentUserToken, "Populate current user"); ClientSessionManager.clearUserCreationRequired(); } finally { duringCreateUser.set(false); } } else { try { currentUser = getUser(currentUserToken); } catch (UserNotInDatabase ex) { if (isGuestAuthenticationAllowed.compareAndSet(true, false)) { ClientSessionManager.authenticateAsGuest(); currentUser = getUser(SystemUser.Guest); } } } } } else { if (isGuestAuthenticationAllowed.compareAndSet(true, false)) { ClientSessionManager.authenticateAsGuest(); currentUser = getUser(SystemUser.Guest); } } if (currentUser == null) { throw new OseeStateException("Setting current user to null."); } else { if (currentUser.getName().equals(SystemUser.Guest.getName())) { if (isGuestNotificationAllowed.compareAndSet(true, false)) { OseeLog.log(Activator.class, Level.INFO, "You are logged into OSEE as \"Guest\". If this is unexpected notify your OSEE admin"); } } } if (ClientSessionManager.isSessionValid()) { AccessControlEvent event = new AccessControlEvent(); event.setEventType(AccessControlEventType.UserAuthenticated); OseeEventManager.kickAccessControlArtifactsEvent(this, event); } return currentUser; }