[jboss-jira] [JBoss JIRA] (WFLY-12814) PreDestroy method not called by stateful beans with timeout 0

Cheng Fang (Jira) issues at jboss.org
Thu Nov 21 07:43:00 EST 2019


     [ https://issues.jboss.org/browse/WFLY-12814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Cheng Fang updated WFLY-12814:
------------------------------
    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.

{code:java}
@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");
    }
}

{code}

  was:
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.



> PreDestroy method not called by stateful beans with timeout 0 
> --------------------------------------------------------------
>
>                 Key: WFLY-12814
>                 URL: https://issues.jboss.org/browse/WFLY-12814
>             Project: WildFly
>          Issue Type: Bug
>          Components: EJB
>    Affects Versions: 18.0.0.Final
>            Reporter: Cheng Fang
>            Assignee: Cheng Fang
>            Priority: Major
>             Fix For: 19.0.0.Beta1
>
>
> 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.
> {code:java}
> @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");
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list