diff options
author | Olivier Lamy <olamy@apache.org> | 2012-02-25 20:45:46 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-02-25 20:45:46 +0000 |
commit | 578d4c98587d0882f1b089d07840c37c66e4dee2 (patch) | |
tree | 1fe6bfcd260df839c461e733155d9edfb611906c /archiva-modules/metadata | |
parent | 31e5bf8148e8489ead707bc137b2e9503b2c844e (diff) | |
download | archiva-578d4c98587d0882f1b089d07840c37c66e4dee2.tar.gz archiva-578d4c98587d0882f1b089d07840c37c66e4dee2.zip |
correctlt close jcr session in case of exception
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1293682 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata')
-rw-r--r-- | archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java index 64ff4077a..84ac9fdcd 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java @@ -19,6 +19,9 @@ package org.apache.archiva.metadata.repository; * under the License. */ +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * The repository session provides a single interface to accessing Archiva repositories. It provides access to three * resources: @@ -40,6 +43,8 @@ public class RepositorySession private boolean dirty; + private Logger log = LoggerFactory.getLogger( getClass() ); + // FIXME: include storage here too - perhaps a factory based on repository ID, or one per type to retrieve and // operate on a given repo within the storage API @@ -60,32 +65,17 @@ public class RepositorySession } public void save() + throws MetadataRepositoryException { - try - { - repository.save(); - } - catch ( MetadataRepositoryException e ) - { - // FIXME - throw new RuntimeException( e ); - } + repository.save(); dirty = false; } public void revert() + throws MetadataRepositoryException { - try - { - repository.revert(); - } - catch ( MetadataRepositoryException e ) - { - // FIXME - throw new RuntimeException( e ); - } - + repository.revert(); dirty = false; } @@ -96,13 +86,24 @@ public class RepositorySession * exception occurs. */ public void close() + throws MetadataRepositoryException { - if ( dirty ) + try { - save(); + if ( dirty ) + { + save(); + } + } + catch ( MetadataRepositoryException e ) + { + // olamy use revert here ? + throw e; + } + finally + { + repository.close(); } - - repository.close(); } public void markDirty() |