From: Olivier Lamy Date: Sun, 17 Feb 2013 23:51:08 +0000 (+0000) Subject: add closeQuietly method for repository session when only reading we can ignore this... X-Git-Tag: archiva-1.4-M4~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b9c19ce3c23c19df115853d1516c7366e95379b9;p=archiva.git add closeQuietly method for repository session when only reading we can ignore this error. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1447103 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index 82a68037e..1e9b8184f 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -703,7 +703,7 @@ public class DefaultBrowseService { if ( session != null ) { - session.close(); + session.closeQuietly(); } } diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java index 4089300c7..0a913c4bb 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java @@ -197,11 +197,18 @@ public interface MetadataRepository throws MetadataRepositoryException; + /** + * implementations can throw RuntimeException + */ void save(); + void close() throws MetadataRepositoryException; + /** + * implementations can throw RuntimeException + */ void revert(); boolean canObtainAccess( Class aClass ); 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 f861ac0d9..115c931de 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 @@ -82,6 +82,7 @@ public class RepositorySession * If the session has been marked as dirty, it will be saved. This may save partial changes in the case of a typical * try { ... } finally { ... } approach - if this is a problem, ensure you revert changes when an * exception occurs. + * can throw RuntimeException */ public void close() { @@ -105,6 +106,18 @@ public class RepositorySession } } + public void closeQuietly() + { + try + { + this.close(); + } + catch ( RuntimeException e ) + { + log.warn( "ignore Runtime exception while closing: {}", e.getMessage() ); + } + } + public void markDirty() {