[ 
https://issues.apache.org/jira/browse/GROOVY-7800?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15211659#comment-15211659
 ] 

Paul King commented on GROOVY-7800:
-----------------------------------

Without looking further into the details, your thinking sounds reasonable to me.

> GroovyMBean does not extract target exception from RuntimeMBeanException
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-7800
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7800
>             Project: Groovy
>          Issue Type: Wish
>          Components: JMX
>    Affects Versions: 2.4.6
>            Reporter: Crazy Gambler
>            Priority: Minor
>
> Hello!
> I would like to get your thoughts on the behavior of {{GroovyMBean}} when 
> handling exceptions.
> I am using Groovy to connect to MBeans written in Java. 
> MBeans may throw checked exceptions or unchecked exceptions. According to 
> Java spec, checked exceptions are wrapped in 
> {{[javax.management.MBeanException|http://docs.oracle.com/javase/7/docs/api/javax/management/MBeanException.html]}}
>  whereas unchecked exceptions are wrapped in 
> {{[javax.management.RuntimeMBeanException|https://docs.oracle.com/javase/7/docs/api/javax/management/RuntimeMBeanException.html]}}.
>  Both the {{RuntimeMBeanException}} and {{MBeanException}} implement a 
> {{getTargetException()}} method that allows you to access the original 
> exception that was thrown in the MBean. 
> When I call an operation on my {{GroovyMBean}} which throws an 
> {{MBeanException}}, the original exception is thrown. This is because the 
> {{GroovyMBean}} implementation extracts the target exception from the 
> {{MBeanException}} 
> (https://github.com/groovy/groovy-core/blob/master/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L111)
> However, when I call an operation on my {{GroovyMBean}} which throws a 
> {{RuntimeMBeanException}}, the wrapper {{RuntimeMBeanException}} is thrown. 
> This is because the {{GroovyMBean}} implementation does not handle extracting 
> the target exception from the {{RuntimeMBeanException}}. 
> This behavior seems inconsistent to me. I think the {{GroovyMBean}} should 
> extract target exception from {{RuntimeMBeanException}} as well. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to