Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-12814

PreDestroy method not called by stateful beans with timeout 0

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 19.0.0.Beta1, 19.0.0.Final
    • 18.0.0.Final
    • EJB
    • None

    Description

      When a stateful bean is configured to have timeout value 0, its preDestroy method is not called when removing it. The expected behavior is the bean should timeout and be eligible for removal immediately (since the stateful timeout is 0), and its preDestroy method is called before the bean is removed.

      The problem seems to be in org.jboss.as.ejb3.cache.simple.SimpleCache, which removes the bean with 0 timeout value directly, instead of submitting it to org.wildfly.clustering.ee.cache.scheduler.LocalScheduler for removal. The direct removal does not have all the proper setup for the preDestroy method to be invoked.

      @Stateful
      @StatefulTimeout(value = 0, unit = TimeUnit.SECONDS)
      
      //when changed @StatefulTimeout to 1, it works as expected.
      //@StatefulTimeout(value = 1, unit = TimeUnit.SECONDS)
      
      public class StatefulHello {
          public void hello() {
          }
      
          @PreDestroy
          private void preDestroy() {
              System.out.printf("## preDestroy in StatefulHello%n");
          }
      }
      
      

      Attachments

        Issue Links

          Activity

            People

              cfang@redhat.com Cheng Fang
              cfang@redhat.com Cheng Fang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: