]> source.dussan.org Git - archiva.git/commitdiff
add closeQuietly method for repository session when only reading we can ignore this...
authorOlivier Lamy <olamy@apache.org>
Sun, 17 Feb 2013 23:51:08 +0000 (23:51 +0000)
committerOlivier Lamy <olamy@apache.org>
Sun, 17 Feb 2013 23:51:08 +0000 (23:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1447103 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java

index 82a68037e33a5af09f5967cf266d7fe0bb623327..1e9b8184f09bf7f5b9c02fc41901f92112cbdc49 100644 (file)
@@ -703,7 +703,7 @@ public class DefaultBrowseService
         {
             if ( session != null )
             {
-                session.close();
+                session.closeQuietly();
             }
         }
 
index 4089300c745461c51ea1e72f873b007ec7b6102d..0a913c4bba0a0ef08b3b31a2ddf3ee108b5452d7 100644 (file)
@@ -197,11 +197,18 @@ public interface MetadataRepository
         throws MetadataRepositoryException;
 
 
+    /**
+     * <b>implementations can throw RuntimeException</b>
+     */
     void save();
 
+
     void close()
         throws MetadataRepositoryException;
 
+    /**
+     * <b>implementations can throw RuntimeException</b>
+     */
     void revert();
 
     boolean canObtainAccess( Class<?> aClass );
index f861ac0d958fe8942387f8465928248cffecb85f..115c931de6407ffe97479132636345541b712b83 100644 (file)
@@ -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
      * <code>try { ... } finally { ... }</code> approach - if this is a problem, ensure you revert changes when an
      * exception occurs.
+     * <b>can throw RuntimeException</b>
      */
     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()
     {