Я получаю предупреждение об обнаружении закрытого сеанса в файле error.log. Я открыл и закрыл все сеансы в блоке finally. Тем не менее я получаю предупреждение. Это сделало экземпляр автора очень медленным из-за большого количества незакрытых сеансов. Вот журналы ошибокНезакрытый сеанс обнаружен в журналах в CQ5
04.06.2015 02:45:54.921 *WARN* [Finalizer] org.apache.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.XASessionImpl.<init>(XASessionImpl.java:117)
at com.day.crx.core.CRXSessionImpl.<init>(CRXSessionImpl.java:69)
at com.day.crx.core.CRXRepositoryImpl.createSessionInstance(CRXRepositoryImpl.java:935)
at org.apache.jackrabbit.core.RepositoryImpl.createSession(RepositoryImpl.java:959)
at org.apache.jackrabbit.core.SessionFactory.createAdminSession(SessionFactory.java:42)
at com.day.crx.sling.server.impl.SlingRepositoryWrapper.loginAdministrative(SlingRepositoryWrapper.java:76)
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getResourceProviderInternal(JcrResourceProviderFactory.java:136)
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getAdministrativeResourceProvider(JcrResourceProviderFactory.java:115)
at org.apache.sling.resourceresolver.impl.tree.ResourceProviderFactoryHandler.login(ResourceProviderFactoryHandler.java:162)
at org.apache.sling.resourceresolver.impl.tree.RootResourceProviderEntry.loginToRequiredFactories(RootResourceProviderEntry.java:95)
at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getResourceResolverInternal(ResourceResolverFactoryImpl.java:95)
at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getAdministrativeResourceResolver(ResourceResolverFactoryImpl.java:69)
at org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext.getResourceTypeResourceResolver(ResourceResolverContext.java:192)
at org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext.getParentResourceType(ResourceResolverContext.java:216)
at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getParentResourceType(ResourceResolverImpl.java:1136)
at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.getParentResourceType(ResourceResolverImpl.java:1126)
at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.isResourceType(ResourceResolverImpl.java:1151)
at org.apache.sling.api.resource.ResourceUtil.isA(ResourceUtil.java:466)
at com.adobe.cq.social.storage.index.AbstractBaseIndexHandler.checkResourceType(AbstractBaseIndexHandler.java:111)
Это фрагмент кода, после которого мы получаем это предупреждение.
private List<String> rollOutPages(Collection<Page> pages) throws Exception
{
final ResourceResolver adminResourceResolver=resourceResolverFactory.getAdministrativeResourceResolver(null);
List<String> rolledOutPages = new ArrayList<>();
try {
//adminResourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
for (Page page : pages) {
final Collection<LiveRelationship> liveRelationships = relationShipManager.getLiveRelationships(page, null, null, false);
for (LiveRelationship relationship : liveRelationships) {
rolloutManager.rollout(adminResourceResolver, relationship, false);
rolledOutPages.add(relationship.getTargetPath());
}
}
adminResourceResolver.adaptTo(Session.class).save();
adminResourceResolver.adaptTo(Session.class).logout();
adminResourceResolver.close();
return rolledOutPages;
}
catch (WCMException e) {
adminResourceResolver.adaptTo(Session.class).save();
adminResourceResolver.adaptTo(Session.class).logout();
adminResourceResolver.close();
LOG.error("Unable to create administrative resource resolver", e);
throw new AbortException("Exception during rollout of pages",e.getMessage());
}
catch (Exception e)
{
adminResourceResolver.adaptTo(Session.class).save();
adminResourceResolver.adaptTo(Session.class).logout();
adminResourceResolver.close();
LOG.error("Exception during rollout of pages", e);
throw new AbortException("Exception during rollout of pages",e.getMessage());
}
finally {
if(adminResourceResolver.isLive()||adminResourceResolver != null){
adminResourceResolver.close();
}
}
}
Я закрыл сеанс в блоке finally. Все еще получаю это предупреждение. Может кто-нибудь, пожалуйста, помогите мне понять, что мне здесь не хватает?