Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-575

ResourceProxyHandler.invoke should unwrap and throw the underlying cause of the InvocationTargetException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0, 1.1.0
    • 1.2.0
    • Java EE Integration, TCK
    • None
    • any

    Description

      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;
      }

      Attachments

        Activity

          People

            struberg Mark Struberg
            kelapure Rohit Dilip Kelapure
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified