You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gg...@apache.org on 2022/09/16 06:46:47 UTC

[karaf] branch karaf-4.2.x updated: [KARAF-7550] Throw the actual target exception of InvocationTargetException in MBean invocation

This is an automated email from the ASF dual-hosted git repository.

ggrzybek pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new 22ad8829d7 [KARAF-7550] Throw the actual target exception of InvocationTargetException in MBean invocation
22ad8829d7 is described below

commit 22ad8829d75fac7dd5bc9ec3657e64dc6a4f2988
Author: Grzegorz Grzybek <gg...@redhat.com>
AuthorDate: Thu Sep 15 14:18:46 2022 +0200

    [KARAF-7550] Throw the actual target exception of InvocationTargetException in MBean invocation
    
    (cherry picked from commit 488d676f796ad3e3bb60818cc7d25edddf2b8576)
---
 .../org/apache/karaf/management/internal/MBeanInvocationHandler.java  | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/management/server/src/main/java/org/apache/karaf/management/internal/MBeanInvocationHandler.java b/management/server/src/main/java/org/apache/karaf/management/internal/MBeanInvocationHandler.java
index 2a5015ea8f..f54c11b66f 100644
--- a/management/server/src/main/java/org/apache/karaf/management/internal/MBeanInvocationHandler.java
+++ b/management/server/src/main/java/org/apache/karaf/management/internal/MBeanInvocationHandler.java
@@ -73,6 +73,10 @@ public class MBeanInvocationHandler implements InvocationHandler {
             });
         } catch (Exception pae) {
             Throwable cause = pae.getCause();
+            if (cause instanceof InvocationTargetException
+                    && ((InvocationTargetException) cause).getTargetException() != null) {
+                cause = ((InvocationTargetException) cause).getTargetException();
+            }
             throw cause == null ? pae:cause;
         }