Ate Douma pushed to branch release/5.0 at cms-community / hippo-repository

Commits:
79148a61 by Ate Douma at 2017-10-06T12:05:17+02:00
REPO-1851 Unwind InvocationTargetException failures when accessing the 
repository

- - - - -


1 changed file:

- connector/src/main/java/org/hippoecm/repository/HippoRepositoryFactory.java


Changes:

=====================================
connector/src/main/java/org/hippoecm/repository/HippoRepositoryFactory.java
=====================================
--- 
a/connector/src/main/java/org/hippoecm/repository/HippoRepositoryFactory.java
+++ 
b/connector/src/main/java/org/hippoecm/repository/HippoRepositoryFactory.java
@@ -152,18 +152,27 @@ public class HippoRepositoryFactory {
         } catch(IllegalAccessException ex) {
             throw new RepositoryException(ex);
         } catch(InvocationTargetException ex) {
-            if (ex.getCause() instanceof RepositoryException) {
-                throw (RepositoryException) ex.getCause();
-            } else if (ex.getCause() instanceof IllegalArgumentException) {
-                throw new RepositoryException("Invalid data: " + 
ex.getCause(), ex);
+            final Throwable cause = unwindInvocationTargetException(ex);
+            if (cause instanceof RepositoryException) {
+                throw (RepositoryException) cause;
+            } else if (cause instanceof IllegalArgumentException) {
+                throw new RepositoryException("Invalid data: " + cause, cause);
             } else {
-                throw new RepositoryException("unchecked exception: " + 
ex.getClass().getName() + ": " + ex.getMessage(), ex);
+                throw new RepositoryException("unchecked exception: " + 
cause.getClass().getName() + ": " + cause.getMessage(), cause);
             }
         }
 
         return repository;
     }
 
+    private static Throwable unwindInvocationTargetException(final 
InvocationTargetException e) {
+        Throwable cause = e.getCause();
+        if (cause != null && cause instanceof InvocationTargetException) {
+            return 
unwindInvocationTargetException((InvocationTargetException)cause);
+        }
+        return cause == null ? e : cause;
+    }
+
     static void unregister(HippoRepository repository) {
         if (repository == defaultRepository) {
             defaultRepository = null;



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-repository/commit/79148a6132dc003394916768fea343101ebeb9e2

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-repository/commit/79148a6132dc003394916768fea343101ebeb9e2
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to