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

Svetlin Zarev updated TOMEE-2051:
---------------------------------
    Description: 
We introduced a regression with (I guess)  TOMEE-2049.

Test cases:
Transnational bean methods:

{code}
//[1] Does not work - transaction is not marked for roll back
    @Transactional(rollbackOn = RollBackException.class)
    public void withRollBackOnWithDeclaredRuntimeException() throws 
RollBackException {
        throw new RollBackException("Roll back because of me! - exception 
declared in throws clause");
    }

//[2]Works as expected
    @Transactional(rollbackOn = RollBackException.class)
    public void withRollBackOnWithoutDeclaredRuntimeException() {
        throw new RollBackException("Roll back because of me! - exception not 
declared in throws clause");
    }
{code}

Where RollbackException is a **RuntimeException**.

In the case where the runtime exception is declared in the throws clause, the 
transaction is not rolled back, although rollbackOn=RollbackException is set.


The root cause is in 
{code}
        private static boolean isNotChecked(final Exception e, final Class<?>[] 
exceptionTypes) {
            return RuntimeException.class.isInstance(e) && 
(exceptionTypes.length == 0 || !asList(exceptionTypes).contains(e.getClass()));
        }
{code}

Here *exceptionTypes* is the passed value of "method.getExceptionTypes()" 
passed from InterceptorBase:104

  was:
We introduced a regression with (I guess)  TOMEE-2049.

Test cases:
Transnational bean methods:

{code}
//[1] Does not work - transaction is not marked for roll back
    @Transactional(rollbackOn = RollBackException.class)
    public void withRollBackOnWithDeclaredRuntimeException() throws 
RollBackException {
        throw new RollBackException("Roll back because of me! - exception 
declared in throws clause");
    }

//[2]Works as expected
    @Transactional(rollbackOn = RollBackException.class)
    public void withRollBackOnWithoutDeclaredRuntimeException() {
        throw new RollBackException("Roll back because of me! - exception not 
declared in throws clause");
    }
{code}

Where RollbackException is a **RuntimeException**.

In the case where the runtime exception is declared in the throws clause, the 
transaction is not rolled back, although rollbackOn=RollbackException is set.


The root cause is in 
{code}
        private static boolean isNotChecked(final Exception e, final Class<?>[] 
exceptionTypes) {
            return RuntimeException.class.isInstance(e) && 
(exceptionTypes.length == 0 || !asList(exceptionTypes).contains(e.getClass()));
        }
{code}

Here *exceptionTypes* is the passed value of "method.getExceptionTypes()"


> JTA 1.2 compliance: @Transactional.rollbackOn regression
> --------------------------------------------------------
>
>                 Key: TOMEE-2051
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2051
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Svetlin Zarev
>
> We introduced a regression with (I guess)  TOMEE-2049.
> Test cases:
> Transnational bean methods:
> {code}
> //[1] Does not work - transaction is not marked for roll back
>     @Transactional(rollbackOn = RollBackException.class)
>     public void withRollBackOnWithDeclaredRuntimeException() throws 
> RollBackException {
>         throw new RollBackException("Roll back because of me! - exception 
> declared in throws clause");
>     }
> //[2]Works as expected
>     @Transactional(rollbackOn = RollBackException.class)
>     public void withRollBackOnWithoutDeclaredRuntimeException() {
>         throw new RollBackException("Roll back because of me! - exception not 
> declared in throws clause");
>     }
> {code}
> Where RollbackException is a **RuntimeException**.
> In the case where the runtime exception is declared in the throws clause, the 
> transaction is not rolled back, although rollbackOn=RollbackException is set.
> The root cause is in 
> {code}
>         private static boolean isNotChecked(final Exception e, final 
> Class<?>[] exceptionTypes) {
>             return RuntimeException.class.isInstance(e) && 
> (exceptionTypes.length == 0 || 
> !asList(exceptionTypes).contains(e.getClass()));
>         }
> {code}
> Here *exceptionTypes* is the passed value of "method.getExceptionTypes()" 
> passed from InterceptorBase:104



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to