From 13b5efc8ccec8b21fc049bbb5332a0713dbdfba1 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 28 Apr 2011 07:45:31 +0000 Subject: [PATCH] Improve session proxy exception handling ASSIGNED - bug 17: Generalize agent management and registration beyond JMS https://bugzilla.argeo.org/show_bug.cgi?id=17 git-svn-id: https://svn.argeo.org/commons/trunk@4483 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../argeo/jcr/ThreadBoundJcrSessionFactory.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/ThreadBoundJcrSessionFactory.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/ThreadBoundJcrSessionFactory.java index 4e9e0a759..003bcc69b 100644 --- a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/ThreadBoundJcrSessionFactory.java +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/ThreadBoundJcrSessionFactory.java @@ -17,6 +17,7 @@ package org.argeo.jcr; import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.ArrayList; @@ -224,7 +225,7 @@ public abstract class ThreadBoundJcrSessionFactory { protected class JcrSessionInvocationHandler implements InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) - throws Throwable { + throws Throwable, RepositoryException { Session threadSession = session.get(); if (threadSession == null) { if ("logout".equals(method.getName()))// no need to login @@ -235,7 +236,16 @@ public abstract class ThreadBoundJcrSessionFactory { } preCall(threadSession); - Object ret = method.invoke(threadSession, args); + Object ret; + try { + ret = method.invoke(threadSession, args); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + if (cause instanceof RepositoryException) + throw (RepositoryException) cause; + else + throw cause; + } if ("logout".equals(method.getName())) { session.remove(); Thread thread = Thread.currentThread(); -- 2.30.2