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:20 UTC

[karaf] branch karaf-4.3.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.3.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


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

commit 8f7b8dfc6c3da5718b4922b7c92b11b43e978898
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 160720427c..a779a45902 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;
         }