X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=server%2Fruntime%2Forg.argeo.server.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjcr%2Fproxy%2FAbstractUrlProxy.java;fp=server%2Fruntime%2Forg.argeo.server.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjcr%2Fproxy%2FAbstractUrlProxy.java;h=8a66f3102dccebf1a1adb76e3c9accede7673f32;hb=ada769fe0be8288e753b3810cce0be2ebc61483c;hp=7692163e3a008a5ea4b70f71fc34e9933c68c93f;hpb=5636f47a1ee7e767fb9e41e8bd863efa1dcedd8c;p=lgpl%2Fargeo-commons.git diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java index 7692163e3..8a66f3102 100644 --- a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/proxy/AbstractUrlProxy.java @@ -78,18 +78,24 @@ public abstract class AbstractUrlProxy implements ResourceProxy { public Node proxy(String path) { // we open a JCR session with client credentials in order not to use the // admin session in multiple thread or make it a bottleneck. + Node nodeAdmin = null; + Node nodeClient = null; Session clientSession = null; try { clientSession = jcrRepository.login(proxyWorkspace); if (!clientSession.itemExists(path) || shouldUpdate(clientSession, path)) { - Node nodeT = retrieveAndSave(path); - if (nodeT == null) - return null; - } - return clientSession.getNode(path); + nodeAdmin = retrieveAndSave(path); + if (nodeAdmin != null) + nodeClient = clientSession.getNode(path); + } else + nodeClient = clientSession.getNode(path); + return nodeClient; } catch (RepositoryException e) { throw new ArgeoException("Cannot proxy " + path, e); + } finally { + if (nodeClient == null) + JcrUtils.logoutQuietly(clientSession); } }