Details
-
Sub-task
-
Resolution: Unresolved
-
Major
-
None
-
AS 4.2.3.GA, 1.0.0-Beta3
-
None
-
None
Description
There's a discrepancy between removing a bean from the cache
after a timeout when bean is in cache compared to when bean is
passivated:
Example, when bean is in cache and has to be removed, this is called:
if (now - centry.lastUsed >= removalTimeout * 1000)
{
synchronized (centry)
}
Now, when bean is passivated, this is called:
if (now - centry.lastUsed >= removalTimeout * 1000)
{
get(centry.getId(), false);
remove(centry.getId());
}
And remove() method calls:
if(log.isTraceEnabled())
{ log.trace("Removing context " + key); } StatefulBeanContext ctx = null;
synchronized (cacheMap)
if(ctx == null)
throw new NoSuchEJBException("Could not find Stateful bean: " + key);
if (!ctx.isRemoved())
container.destroy(ctx);
++removeCount;
if (ctx.getCanRemoveFromCache())
{
synchronized (cacheMap)
}
What this means is that when a bean in cache is removed:
1.- removeCount is not updated
2.- container.destroy(ctx); is not executed and hence the @PreDestroy
method is not executed either. With regards to this, spec says:
Spec 4.4 "Note that a container can also invoke the PreDestroy method
on the instance without a client call to remove the session object after
the lifetime of the EJB object has expired."