我正在使用Jackrabbit 2.13.1。
为什么AccessDeniedException导致会话泄漏?
try {
session = repository.login(creds); //here are creds for user without permissions, just for testing
} catch (Throwable t) {
if (session != null) {
session.logout();
}
Throwables.propagateIfInstanceOf(t, javax.jcr.RepositoryException.class);
throw Throwables.propagate(t);
}
正如预期的那样抛出AccessDeniedException:
Caused by: javax.jcr.LoginException: Workspace access denied
at org.apache.jackrabbit.core.RepositoryImpl.login(RepositoryImpl.java:1529)
at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:144)
at ttt.createSession(RepositoryManager.java:132)
... 51 common frames omitted
Caused by: javax.jcr.AccessDeniedException: Not allowed to access Workspace default
at org.apache.jackrabbit.core.security.DefaultAccessManager.init(DefaultAccessManager.java:159)
at org.apache.jackrabbit.core.DefaultSecurityManager.getAccessManager(DefaultSecurityManager.java:280)
at org.apache.jackrabbit.core.SessionImpl.createAccessManager(SessionImpl.java:356)
at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:273)
at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:239)
at org.apache.jackrabbit.core.XASessionImpl.<init>(XASessionImpl.java:101)
at org.apache.jackrabbit.core.RepositoryImpl.createSessionInstance(RepositoryImpl.java:1613)
at org.apache.jackrabbit.core.RepositoryImpl.createSession(RepositoryImpl.java:956)
at org.apache.jackrabbit.core.RepositoryImpl.login(RepositoryImpl.java:1501)
会话为空,所以我无法在其上调用logout。但是抛出未关闭的会话检测到的异常:
WARN o.a.jackrabbit.core.SessionImpl - Unclosed session detected. The session was opened here:
java.lang.Exception: Stack Trace
at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:222)
at org.apache.jackrabbit.core.SessionImpl.<init>(SessionImpl.java:239)
at org.apache.jackrabbit.core.XASessionImpl.<init>(XASessionImpl.java:101)
at org.apache.jackrabbit.core.RepositoryImpl.createSessionInstance(RepositoryImpl.java:1613)
at org.apache.jackrabbit.core.RepositoryImpl.createSession(RepositoryImpl.java:956)
at org.apache.jackrabbit.core.RepositoryImpl.login(RepositoryImpl.java:1501)
at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:144)
at ttt.createSession(RepositoryManager.java:132)
答案 0 :(得分:1)
好的捕获,这听起来显然是一个错误仍然存在于2.13.3
中并且在SessionImpl
的构造函数中抛出异常时发生,会话是然后部分创建,但它仍然被认为是活着的,即将被GCed的实时会话被当前代码视为会话泄漏,这就是你得到这个警告的原因。