You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Mark Struberg (JIRA)" <ji...@apache.org> on 2013/04/10 22:57:16 UTC

[jira] [Resolved] (OWB-575) ResourceProxyHandler.invoke should unwrap and throw the underlying cause of the InvocationTargetException

     [ https://issues.apache.org/jira/browse/OWB-575?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg resolved OWB-575.
-------------------------------

    Resolution: Fixed
      Assignee: Mark Struberg  (was: Gurkan Erdogdu)

the whole class got ditched -> problem gone
                
> ResourceProxyHandler.invoke should unwrap and throw the underlying cause of the InvocationTargetException
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: OWB-575
>                 URL: https://issues.apache.org/jira/browse/OWB-575
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Java EE Integration, TCK
>    Affects Versions: 1.0.0, 1.1.0
>         Environment: any
>            Reporter: Rohit Dilip Kelapure
>            Assignee: Mark Struberg
>             Fix For: 1.2.0
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Right now the ResourceProxyHandler simply rethrows the exception resulting from an invoke.
> There may be cases where the ResourceProxyHandler needs to throw the root cause of the exception upstream instead of the wrapped InvocationException.
> ResourceProxyHandler.invoke needs to unwrap the root cause exception from the invoke and pass it up the chain since.
> This change is conceptually similar to https://issues.apache.org/jira/browse/OWB-554
> This defect is needed to resolve a org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext.PersistenceContextInjectionTest TCK failure since the TCK looks for  the IllegalStateException as noted below.
>       try
>       {
>          entityManager.getTransaction(); // <--
>          entityManagerValid = false;
>       }
>       catch (IllegalStateException e)
>       {
>          // an IllegalStateException is the expected result if this is a JTA entityManager
> 	}
> An IllegalStateException is not caught though - because it looks like it is being wrapped by a java.lang.reflect.InvocationTargetException.
> proposed Fix: 
>     @Override
>     public Object invoke(Object self, Method actualMethod, Method proceed, Object[] args) throws Throwable
>     {
> 		Object rc = null;
> 		try {
> 			rc = actualMethod.invoke(this.actualResource, args);
> 		} catch (InvocationTargetException ite) {
> 			throw ite.getCause();
> 		} catch (IllegalArgumentException e) {
> 			throw e.getCause();
> 		} catch (IllegalAccessException e) {
> 			throw e.getCause();
> 		}
> 		return rc;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira