0 Replies Latest reply on Mar 22, 2006 10:38 PM by adver11

    a bug about @Timeout ?

    adver11

      Look below code:

      @Stateless
      @Local(FidsConJob.class)
      public class FidsConJobBean implements FidsConJob {
       private Timer ConJob;
      
       public void startup() {
       ConJob = ctx.getTimerService().createTimer(new Date(System.currentTimeMillis()), 6000, "FidsConJob");
       }
      
       @Timeout
       public void timeoutHandler(Timer timer) {
       if(timer.equals(ConJob)) System.out.println("Same timer");
       else
       System.out.println("Different timer");
       }
      }

      JBoss 4.0.4 RC1 shows:
      11:24:09,630 INFO [STDOUT] Different timer

      it means ConJob not equals timer.

      Look another below code:
      @Stateless
      @Local(FidsConJob.class)
      public class FidsConJobBean implements FidsConJob {
       private Timer ConJob;
      
       public void startup() {
       ConJob = ctx.getTimerService().createTimer(new Date(System.currentTimeMillis()), 6000, "FidsConJob");
       }
      
       @Timeout
       public void timeoutHandler(Timer timer) {
       if(ConJob.equals(timer)) System.out.println("Same timer");
       else
       System.out.println("Different timer");
       }
      }

      JBoss 4.0.4 RC1 shows:
      11:27:44,909 ERROR [TimerImpl] Error invoking ejbTimeout: javax.ejb.EJBException
      : java.lang.NullPointerException

      First, timer.equals(ConJob) and ConJob.equals(timer) get different result.

      Second, in ejb-3_0-pfd-spec-ejbcore.pdf:
      17.2.2 Timeout Callbacks
      If the timed object needs to make use of the identity of the timer to recognize the significance of the
      timer expiration, it may use the equals method to compare it with any other timer references it might
      have outstanding.
      17.2.4 Timer Identity
      The Bean Provider cannot rely on the == operator to compare timers for ?object equality?. The Bean
      Provider must use the Timer.equals(Object obj) method.


      I think it's a bug.