Commit 9092a77d42575e127b57325d726e41140be3a6f3
1 parent
60643ca5
Exists in
master
Tentativa de correção de uma falha de NullPointerException que ocorre no
Apache OpenWebBeans
Showing
1 changed file
with
11 additions
and
9 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptor.java
@@ -69,11 +69,11 @@ public class ExceptionHandlerInterceptor implements Serializable { | @@ -69,11 +69,11 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
69 | 69 | ||
70 | private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); | 70 | private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); |
71 | 71 | ||
72 | - private final boolean handleException(final Exception cause, final InvocationContext ic) throws Exception { | 72 | + private final boolean handleException(final Exception cause, final Object target) throws Exception { |
73 | getLogger().info(getBundle().getString("handling-exception", cause.getClass().getCanonicalName())); | 73 | getLogger().info(getBundle().getString("handling-exception", cause.getClass().getCanonicalName())); |
74 | 74 | ||
75 | boolean handled = false; | 75 | boolean handled = false; |
76 | - Class<?> type = getType(ic); | 76 | + Class<?> type = getType(target); |
77 | 77 | ||
78 | if (!isLoaded(type)) { | 78 | if (!isLoaded(type)) { |
79 | loadHandlers(type); | 79 | loadHandlers(type); |
@@ -81,22 +81,22 @@ public class ExceptionHandlerInterceptor implements Serializable { | @@ -81,22 +81,22 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
81 | 81 | ||
82 | Method handler = getMethod(type, cause); | 82 | Method handler = getMethod(type, cause); |
83 | if (handler != null) { | 83 | if (handler != null) { |
84 | - invoke(handler, ic.getTarget(), cause); | 84 | + invoke(handler, target, cause); |
85 | handled = true; | 85 | handled = true; |
86 | } | 86 | } |
87 | 87 | ||
88 | return handled; | 88 | return handled; |
89 | } | 89 | } |
90 | 90 | ||
91 | - private final Class<?> getType(final InvocationContext ic) { | ||
92 | - Class<?> type = ic.getTarget().getClass(); | 91 | + private final Class<?> getType(final Object target) { |
92 | + Class<?> type = target.getClass(); | ||
93 | CoreBootstrap bootstrap = Beans.getReference(CoreBootstrap.class); | 93 | CoreBootstrap bootstrap = Beans.getReference(CoreBootstrap.class); |
94 | 94 | ||
95 | if (!bootstrap.isAnnotatedType(type)) { | 95 | if (!bootstrap.isAnnotatedType(type)) { |
96 | - type = type.getSuperclass(); | ||
97 | getLogger().debug( | 96 | getLogger().debug( |
98 | - getBundle().getString("proxy-detected", ic.getTarget().getClass(), | ||
99 | - ic.getTarget().getClass().getSuperclass())); | 97 | + getBundle().getString("proxy-detected", type, |
98 | + type.getSuperclass())); | ||
99 | + type = type.getSuperclass(); | ||
100 | } | 100 | } |
101 | 101 | ||
102 | return type; | 102 | return type; |
@@ -183,13 +183,15 @@ public class ExceptionHandlerInterceptor implements Serializable { | @@ -183,13 +183,15 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
183 | 183 | ||
184 | @AroundInvoke | 184 | @AroundInvoke |
185 | public Object manage(final InvocationContext ic) throws Exception { | 185 | public Object manage(final InvocationContext ic) throws Exception { |
186 | + Object target = null; | ||
186 | Object result = null; | 187 | Object result = null; |
187 | 188 | ||
188 | try { | 189 | try { |
190 | + target = ic.getTarget(); | ||
189 | result = ic.proceed(); | 191 | result = ic.proceed(); |
190 | 192 | ||
191 | } catch (Exception cause) { | 193 | } catch (Exception cause) { |
192 | - if (!handleException(cause, ic)) { | 194 | + if (!handleException(cause, target)) { |
193 | throw cause; | 195 | throw cause; |
194 | } | 196 | } |
195 | } | 197 | } |