User: simone
Date: 00/11/29 18:19:48
Modified: src/main/org/jboss/ejb/plugins EnterpriseInstanceCache.java
Log:
Fixed 2 minor bugs:
1) on release, don't call remove(id) anymore, but only remove the bean from the cache
2) on passivation, check that the bean hasn't been requested, and hence reinserted
in the cache, before passivation occurs.
Revision Changes Path
1.7 +21 -4
jboss/src/main/org/jboss/ejb/plugins/EnterpriseInstanceCache.java
Index: EnterpriseInstanceCache.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/EnterpriseInstanceCache.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EnterpriseInstanceCache.java 2000/11/23 22:15:43 1.6
+++ EnterpriseInstanceCache.java 2000/11/30 02:19:48 1.7
@@ -37,7 +37,7 @@
* </ul>
*
* @author Simone Bordet ([EMAIL PROTECTED])
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public abstract class EnterpriseInstanceCache
implements InstanceCache, XmlLoadable
@@ -119,8 +119,18 @@
public void release(EnterpriseContext ctx)
{
if (ctx == null) throw new IllegalArgumentException("Can't release a
null object");
-
- remove(getKey(ctx));
+
+ // Here I remove the bean; call to remove(id) is wrong
+ // cause will remove also the cache lock that is needed
+ // by the passivation, that eventually will remove it.
+ Object id = getKey(ctx);
+ synchronized (getCacheLock())
+ {
+ if (getCache().peek(id) != null)
+ {
+ getCache().remove(id);
+ }
+ }
schedulePassivation(ctx);
}
/* From InstanceCache interface */
@@ -326,7 +336,14 @@
{
synchronized (getCacheLock())
{
- getCache().insert(id,
ctx);
+ // This check is done
because there could have been
+ // a request for
passivation of this bean, but before
+ // being passivated it
got a request and has already
+ // been inserted in
the cache by the instance interceptor
+ if
(getCache().peek(id) == null)
+ {
+
getCache().insert(id, ctx);
+ }
}
return;
}