Skip to content

Commit

Permalink
Merge pull request #1 from stuartwdouglas/master
Browse files Browse the repository at this point in the history
Remove code that treated unchecked exceptions in the throws cause as an application exception
  • Loading branch information
jaikiran committed Jun 3, 2011
2 parents cbb2730 + 848e384 commit 9742b9b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public abstract class CMTTxInterceptor

/**
* Returns the {@link TransactionalComponent} applicable for this interceptor
*
* @return
*/
protected abstract TransactionalComponent getTransactionalComponent();
Expand Down Expand Up @@ -148,13 +147,6 @@ protected void handleInCallerTx(InvocationContext invocation, Throwable t, Trans
throw (Exception) t;
}

// if it's part of throws clause, then treat it as an application exception (section 14.2.1 of EJB3.1 spec)
Method invokedMethod = invocation.getMethod();
if (invokedMethod != null && this.isPartOfThrowsClause(invokedMethod, t))
{
throw (Exception) t;
}

// if it's not EJBTransactionRolledbackException
if (!(t instanceof EJBTransactionRolledbackException))
{
Expand Down Expand Up @@ -186,7 +178,7 @@ else if (t instanceof RuntimeException)
throw (Exception) t;
}

protected void handleExceptionInOurTx(InvocationContext invocation, Throwable t, Transaction tx) throws Exception
public void handleExceptionInOurTx(InvocationContext invocation, Throwable t, Transaction tx) throws Exception
{
ApplicationException ae = this.getApplicationException(t.getClass());
if (ae != null)
Expand All @@ -198,13 +190,6 @@ protected void handleExceptionInOurTx(InvocationContext invocation, Throwable t,
throw (Exception) t;
}

// if it's part of throws clause, then treat it as an application exception (section 14.2.1 of EJB3.1 spec)
Method invokedMethod = invocation.getMethod();
if (invokedMethod != null && this.isPartOfThrowsClause(invokedMethod, t))
{
throw (Exception) t;
}

// if it's neither EJBException nor RemoteException
if (!(t instanceof EJBException || t instanceof RemoteException))
{
Expand Down Expand Up @@ -492,25 +477,4 @@ private ApplicationException getApplicationException(Class<?> exceptionClass)
TransactionalComponent txComponent = this.getTransactionalComponent();
return txComponent.getApplicationException(exceptionClass);
}

/**
* Returns true if the passed {@link Throwable} is part of the throws clause of the passed {@link Method}.
* Else, returns false.
*
* @param m The method whose throws clause will be checked
* @param t The Throwable which will be compared against the throws clause of the passed method
* @return
*/
private boolean isPartOfThrowsClause(Method m, Throwable t)
{
Class<?>[] exceptionTypes = m.getExceptionTypes();
for (Class<?> exceptionType : exceptionTypes)
{
if (exceptionType.equals(t.getClass()))
{
return true;
}
}
return false;
}
}

This file was deleted.

48 changes: 0 additions & 48 deletions tx/impl/src/test/java/org/jboss/ejb3/tx2/impl/test/SimpleBean.java

This file was deleted.

This file was deleted.

0 comments on commit 9742b9b

Please sign in to comment.