code.onehippo.org is currently readonly. We are migrating to code.bloomreach.com, please continue working there on Monday 14/12. See: https://docs.bloomreach.com/display/engineering/GitLab

Commit 79148a61 authored by Ate Douma's avatar Ate Douma

REPO-1851 Unwind InvocationTargetException failures when accessing the repository

parent 4d981c03
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment