if (SecurityContextHolder.getContext().getAuthentication() == null) {
// authentication
- systemExecutor.execute(action);
- JcrUtils.logoutQuietly(session);
+ try {
+ systemExecutor.execute(action);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ }
} else {
// authenticated user
action.run();
if (log.isDebugEnabled())
log.debug("Mapped " + ctx.getDn() + " to " + userProfile);
return userHomePath;
- } catch (RepositoryException e) {
+ } catch (Exception e) {
JcrUtils.discardQuietly(session);
throw new ArgeoException("Cannot synchronize JCR and LDAP", e);
} finally {