remm        01/08/31 10:48:49

  Modified:    src/share/org/apache/slide/store AbstractStore.java
  Log:
  - Improve robustness by catching all unhandled throwables and wrapping
    inside a ServiceAccessException.
  - Also fix a problem where a RuntimeException or an Error thrown from a store
    wouldn't cause it to be properly delisted with a failure status.
  
  Revision  Changes    Path
  1.19      +182 -17   
jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java
  
  Index: AbstractStore.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AbstractStore.java        2001/08/30 14:56:57     1.18
  +++ AbstractStore.java        2001/08/31 17:48:49     1.19
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java,v 1.18 
2001/08/30 14:56:57 remm Exp $
  - * $Revision: 1.18 $
  - * $Date: 2001/08/30 14:56:57 $
  + * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/AbstractStore.java,v 1.19 
2001/08/31 17:48:49 remm Exp $
  + * $Revision: 1.19 $
  + * $Date: 2001/08/31 17:48:49 $
    *
    * ====================================================================
    *
  @@ -89,7 +89,7 @@
    * Abstract implementation of a store. Handles all caching operations.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  - * @version $Revision: 1.18 $
  + * @version $Revision: 1.19 $
    */
   public abstract class AbstractStore extends AbstractSimpleService
       implements Store {
  @@ -499,10 +499,23 @@
                   // transaction won't be always rolledback when committed)
                   delist(nodeStore);
                   throw e;
  +            } catch (Throwable t) {
  +                delist(nodeStore, false);
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException(nodeStore, t.getMessage());
               }
               delist(nodeStore);
           } else {
  -            objectNode = nodeStore.retrieveObject(uri);
  +            try {
  +                objectNode = nodeStore.retrieveObject(uri);
  +            } catch (ServiceAccessException e) {
  +                throw e;
  +            } catch (ObjectNotFoundException e) {
  +                throw e;
  +            } catch (Throwable t) {
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException(nodeStore, t.getMessage());
  +            }
           }
           objectNode.validate(uri.toString());
           return objectNode;
  @@ -529,6 +542,10 @@
           } catch (ObjectNotFoundException e) {
               delist(nodeStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(nodeStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(nodeStore, t.getMessage());
           }
           delist(nodeStore);
       }
  @@ -556,6 +573,10 @@
           } catch (ObjectAlreadyExistsException e) {
               delist(nodeStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(nodeStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(nodeStore, t.getMessage());
           }
           delist(nodeStore);
       }
  @@ -580,6 +601,10 @@
           } catch (ObjectNotFoundException e) {
               delist(nodeStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(nodeStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(nodeStore, t.getMessage());
           }
           delist(nodeStore);
       }
  @@ -601,6 +626,10 @@
           } catch (ServiceAccessException e) {
               delist(securityStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(securityStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(securityStore, t.getMessage());
           }
           delist(securityStore);
       }
  @@ -621,6 +650,10 @@
           } catch (ServiceAccessException e) {
               delist(securityStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(securityStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(securityStore, t.getMessage());
           }
           delist(securityStore);
       }
  @@ -640,6 +673,10 @@
           } catch (ServiceAccessException e) {
               delist(securityStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(securityStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(securityStore, t.getMessage());
           }
           delist(securityStore);
       }
  @@ -662,11 +699,24 @@
               } catch (ServiceAccessException e) {
                   delist(securityStore, false);
                   throw e;
  +            } catch (Throwable t) {
  +                delist(securityStore, false);
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (securityStore, t.getMessage());
               }
               delist(securityStore);
               return permissions;
           } else {
  -            return securityStore.enumeratePermissions(uri);
  +            try {
  +                return securityStore.enumeratePermissions(uri);
  +            } catch (ServiceAccessException e) {
  +                throw e;
  +            } catch (Throwable t) {
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (securityStore, t.getMessage());
  +            }
           }
       }
       
  @@ -686,6 +736,10 @@
           } catch (ServiceAccessException e) {
               delist(lockStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(lockStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(lockStore, t.getMessage());
           }
           delist(lockStore);
       }
  @@ -710,6 +764,10 @@
           } catch (LockTokenNotFoundException e) {
               delist(lockStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(lockStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(lockStore, t.getMessage());
           }
           delist(lockStore);
       }
  @@ -734,6 +792,10 @@
           } catch (LockTokenNotFoundException e) {
               delist(lockStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(lockStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(lockStore, t.getMessage());
           }
           delist(lockStore);
       }
  @@ -758,6 +820,10 @@
           } catch (LockTokenNotFoundException e) {
               delist(lockStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(lockStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(lockStore, t.getMessage());
           }
           delist(lockStore);
       }
  @@ -780,11 +846,22 @@
               } catch (ServiceAccessException e) {
                   delist(lockStore, false);
                   throw e;
  +            } catch (Throwable t) {
  +                delist(lockStore, false);
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException(lockStore, t.getMessage());
               }
               delist(lockStore);
               return locks;
           } else {
  -            return lockStore.enumerateLocks(uri);
  +            try {
  +                return lockStore.enumerateLocks(uri);
  +            } catch (ServiceAccessException e) {
  +                throw e;
  +            } catch (Throwable t) {
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException(lockStore, t.getMessage());
  +            }
           }
       }
       
  @@ -812,11 +889,26 @@
                   // Normal read failures aren't considered fatal
                   delist(revisionDescriptorsStore);
                   throw e;
  +            } catch (Throwable t) {
  +                delist(revisionDescriptorsStore, false);
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (revisionDescriptorsStore, t.getMessage());
               }
               delist(revisionDescriptorsStore);
           } else {
  -            revisionDescriptors =
  -                revisionDescriptorsStore.retrieveRevisionDescriptors(uri);
  +            try {
  +                revisionDescriptors =
  +                    revisionDescriptorsStore.retrieveRevisionDescriptors(uri);
  +            } catch (ServiceAccessException e) {
  +                throw e;
  +            } catch (RevisionDescriptorNotFoundException e) {
  +                throw e;
  +            } catch (Throwable t) {
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (revisionDescriptorsStore, t.getMessage());
  +            }
           }
           revisionDescriptors.validate(uri.toString());
           return revisionDescriptors;
  @@ -841,6 +933,11 @@
           } catch (ServiceAccessException e) {
               delist(revisionDescriptorsStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(revisionDescriptorsStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException
  +                (revisionDescriptorsStore, t.getMessage());
           }
           delist(revisionDescriptorsStore);
       }
  @@ -869,6 +966,11 @@
           } catch (RevisionDescriptorNotFoundException e) {
               delist(revisionDescriptorsStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(revisionDescriptorsStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException
  +                (revisionDescriptorsStore, t.getMessage());
           }
           delist(revisionDescriptorsStore);
       }
  @@ -888,6 +990,11 @@
           } catch (ServiceAccessException e) {
               delist(revisionDescriptorsStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(revisionDescriptorsStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException
  +                (revisionDescriptorsStore, t.getMessage());
           }
           delist(revisionDescriptorsStore);
       }
  @@ -910,18 +1017,33 @@
                       revisionDescriptorStore.retrieveRevisionDescriptor
                       (uri, revisionNumber);
               } catch (ServiceAccessException e) {
  -                delist(revisionDescriptorsStore, false);
  +                delist(revisionDescriptorStore, false);
                   throw e;
               } catch (RevisionDescriptorNotFoundException e) {
                   // Normal read failures aren't considered fatal
  -                delist(revisionDescriptorsStore);
  +                delist(revisionDescriptorStore);
                   throw e;
  +            } catch (Throwable t) {
  +                delist(revisionDescriptorStore, false);
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (revisionDescriptorStore, t.getMessage());
               }
  -            delist(revisionDescriptorsStore);
  +            delist(revisionDescriptorStore);
           } else {
  -            revisionDescriptor =
  -                revisionDescriptorStore.retrieveRevisionDescriptor
  -                (uri, revisionNumber);
  +            try {
  +                revisionDescriptor =
  +                    revisionDescriptorStore.retrieveRevisionDescriptor
  +                    (uri, revisionNumber);
  +            } catch (ServiceAccessException e) {
  +                throw e;
  +            } catch (RevisionDescriptorNotFoundException e) {
  +                throw e;
  +            } catch (Throwable t) {
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (revisionDescriptorStore, t.getMessage());
  +            }
           }
           revisionDescriptor.validate();
           return revisionDescriptor;
  @@ -946,6 +1068,11 @@
           } catch (ServiceAccessException e) {
               delist(revisionDescriptorStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(revisionDescriptorStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException
  +                (revisionDescriptorStore, t.getMessage());
           }
           delist(revisionDescriptorStore);
       }
  @@ -974,6 +1101,11 @@
           } catch (RevisionDescriptorNotFoundException e) {
               delist(revisionDescriptorStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(revisionDescriptorStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException
  +                (revisionDescriptorStore, t.getMessage());
           }
           delist(revisionDescriptorStore);
       }
  @@ -995,6 +1127,11 @@
           } catch (ServiceAccessException e) {
               delist(revisionDescriptorStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(revisionDescriptorStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException
  +                (revisionDescriptorStore, t.getMessage());
           }
           delist(revisionDescriptorStore);
       }
  @@ -1023,11 +1160,27 @@
                   // Normal read failures aren't considered fatal
                   delist(contentStore);
                   throw e;
  +            } catch (Throwable t) {
  +                delist(contentStore, false);
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (contentStore, t.getMessage());
               }
               delist(contentStore);
           } else {
  -            revisionContent =
  -                contentStore.retrieveRevisionContent(uri, revisionDescriptor);
  +            try {
  +                revisionContent =
  +                    contentStore.retrieveRevisionContent
  +                    (uri, revisionDescriptor);
  +            } catch (ServiceAccessException e) {
  +                throw e;
  +            } catch (RevisionNotFoundException e) {
  +                throw e;
  +            } catch (Throwable t) {
  +                // Wrap everything else in a ServiceAccessException
  +                throw new ServiceAccessException
  +                    (contentStore, t.getMessage());
  +            }
           }
           revisionContent.validate();
           return revisionContent;
  @@ -1057,6 +1210,10 @@
           } catch (RevisionAlreadyExistException e) {
               delist(contentStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(contentStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(contentStore, t.getMessage());
           }
           delist(contentStore);
       }
  @@ -1085,6 +1242,10 @@
           } catch (RevisionNotFoundException e) {
               delist(contentStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(contentStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(contentStore, t.getMessage());
           }
           delist(contentStore);
       }
  @@ -1106,6 +1267,10 @@
           } catch (ServiceAccessException e) {
               delist(contentStore, false);
               throw e;
  +        } catch (Throwable t) {
  +            delist(contentStore, false);
  +            // Wrap everything else in a ServiceAccessException
  +            throw new ServiceAccessException(contentStore, t.getMessage());
           }
           delist(contentStore);
       }
  
  
  

Reply via email to