This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.contentloader-2.0.4-incubator in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
commit 94f72a0bdfbf73d30727f3692ce8837548734466 Author: Carsten Ziegeler <[email protected]> AuthorDate: Wed Jan 21 08:59:53 2009 +0000 SLING-838 : Clean up code, use method for session logout. git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/contentloader@736268 13f79535-47bb-0310-9956-ffa450edef68 --- .../internal/ContentLoaderService.java | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java b/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java index c454fe5..1f94f63 100644 --- a/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java +++ b/src/main/java/org/apache/sling/jcr/contentloader/internal/ContentLoaderService.java @@ -128,7 +128,7 @@ public class ContentLoaderService implements SynchronousBundleListener { // as node types are registered when the bundle is installed // we can safely add the content at this point. try { - session = getAdminSession(); + session = this.getSession(); final boolean isUpdate = this.updatedBundles.remove(event.getBundle().getSymbolicName()); initialContentLoader.registerBundle(session, event.getBundle(), isUpdate); } catch (Throwable t) { @@ -137,9 +137,7 @@ public class ContentLoaderService implements SynchronousBundleListener { + event.getBundle().getSymbolicName() + " (" + event.getBundle().getBundleId() + ")", t); } finally { - if ( session != null ) { - session.logout(); - } + this.ungetSession(session); } break; case BundleEvent.UPDATED: @@ -149,7 +147,7 @@ public class ContentLoaderService implements SynchronousBundleListener { break; case BundleEvent.UNINSTALLED: try { - session = getAdminSession(); + session = this.getSession(); initialContentLoader.unregisterBundle(session, event.getBundle()); } catch (Throwable t) { log.error( @@ -157,9 +155,7 @@ public class ContentLoaderService implements SynchronousBundleListener { + event.getBundle().getSymbolicName() + " (" + event.getBundle().getBundleId() + ")", t); } finally { - if ( session != null ) { - session.logout(); - } + this.ungetSession(session); } break; } @@ -211,7 +207,7 @@ public class ContentLoaderService implements SynchronousBundleListener { Session session = null; try { - session = this.getAdminSession(); + session = this.getSession(); this.createRepositoryPath(session, ContentLoaderService.BUNDLE_CONTENT_NODE); log.debug( "Activated - attempting to load content from all " @@ -250,9 +246,7 @@ public class ContentLoaderService implements SynchronousBundleListener { log.error("activate: Problem while loading initial content and" + " registering mappings for existing bundles", t); } finally { - if ( session != null ) { - session.logout(); - } + this.ungetSession(session); } } @@ -276,12 +270,25 @@ public class ContentLoaderService implements SynchronousBundleListener { /** * Returns an administrative session to the default workspace. */ - private Session getAdminSession() + private Session getSession() throws RepositoryException { return getRepository().loginAdministrative(null); } /** + * Return the administrative session and close it. + */ + private void ungetSession(final Session session) { + if ( session != null ) { + try { + session.logout(); + } catch (Throwable t) { + log.error("Unable to log out of session: " + t.getMessage(), t); + } + } + } + + /** * Return the bundle content info and make an exclusive lock. * @param session * @param bundle -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
