0 Replies Latest reply on Apr 27, 2005 10:24 PM by Boris Zozoulia

    jboss 4.0.1sp1: org.jboss.ejb.txttimer.TimerImpl has bug ?

    Boris Zozoulia Newbie

      Cancelling timer does not kill timer thread if timer is within transaction.

      There was a post already on this forum - but it still remains unanswered. Let me rise this issue up again:

      according to org.jboss.ejb.txttimer.TimerImpl code timer can be killed in 3 and only 3 cases:

      1: When we are changing timer state and timer state is EXPIRED.

       private void setTimerState(int state)
       {
       log.debug("setTimerState: " + TIMER_STATES[state]);
       timerState = state;
      
       // get rid of the expired timer
       if (timerState == EXPIRED)
       killTimer();
       }
      


      2: When we are cancelling timer and timer is not contained within transaction:
       private void cancelInTx()
       {
       TimerServiceImpl timerService = getTimerService();
       if (timerService.getTransaction() != null)
       setTimerState(CANCELED_IN_TX);
       else
       killTimer();
       }
      


      3: When timer is contained within the transaction and the afterCompletion method is called and this transaction is in ROLLBACK state:
       public void afterCompletion(int status)
       {
       if (status == Status.STATUS_COMMITTED)
       {
       // ... code is omitted for the sake of space saving
       }
      
       if (status == Status.STATUS_ROLLEDBACK)
       {
       log.debug("rollback: " + this);
      
       if (timerState == STARTED_IN_TX)
       killTimer();
       else if (timerState == CANCELED_IN_TX)
       setTimerState(ACTIVE);
       else if (timerState == IN_TIMEOUT)
       // ... code is omitted for the sake of space saving
       }
       }
      


      But what happens if timer is not contained within the transaction, i.e. transaction was declared as NotSupported.

      According to 2 timer will be setTimerState(CANCELED_IN_TX); and then in CANCELED, but killTimer() will never get called resulting timer thread just to hang in a memory and do nothing.

      Is it a bug a feature?