User: patriot1burke
  Date: 01/06/17 07:57:53

  Modified:    src/main/org/jboss/ejb/plugins AbstractInstanceCache.java
  Log:
  In PassivatorJob, check to see if ctx.getId() is null just in case the ctx has
  already been passivated.
  
  Added key parameter to canPassivate(..) so that it
  can verify that the object being passivated is really the
  same object and hasn't already been freed then re-used.
  
  Revision  Changes    Path
  1.9       +60 -56    jboss/src/main/org/jboss/ejb/plugins/AbstractInstanceCache.java
  
  Index: AbstractInstanceCache.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/AbstractInstanceCache.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractInstanceCache.java        2001/06/15 23:35:05     1.8
  +++ AbstractInstanceCache.java        2001/06/17 14:57:53     1.9
  @@ -57,7 +57,7 @@
    *
    * @author Simone Bordet ([EMAIL PROTECTED])
    * @author <a href="[EMAIL PROTECTED]">Bill Burke</a>
  - * @version $Revision: 1.8 $
  + * @version $Revision: 1.9 $
    */
   public abstract class AbstractInstanceCache
        implements InstanceCache, XmlLoadable, Monitorable, MetricsConstants
  @@ -565,8 +565,12 @@
        protected abstract void setKey(Object id, EnterpriseContext ctx);
        /**
         * Returns whether the given context can be passivated or not
  +      *
  +      * (Bill Burke> added key parameter so that canPassivate
  +      * can verify that the object being passivated is really the
  +      * same object and hasn't already been freed then re-used.
         */
  -     protected abstract boolean canPassivate(EnterpriseContext ctx);
  +     protected abstract boolean canPassivate(Object key, EnterpriseContext ctx);
   
        // Private -------------------------------------------------------
   
  @@ -602,15 +606,15 @@
                                        public void execute() throws Exception
                                        {
                                                EnterpriseContext ctx = 
this.getEnterpriseContext();
  -                                             Object id = this.getKey();
  -
  -                                             if (id == null)
  +                                             if (ctx.getId() == null)
                                                {
  -                                                     // If this happens, then a 
passivation request for this bean was issued
  -                                                     // but not yet executed, and 
in the meanwhile the bean has been removed.
  -                                                     return;
  +                                                 // If this happens, then a 
passivation request for this bean was issued
  +                                                 // but not yet executed, and in 
the meanwhile the bean has been removed.
  +                                                 return;
                                                }
   
  +                                             Object id = this.getKey();
  +
                                                /**
                                                 * Synchronization / Passivation 
explanations:
                                                 * The instance interceptor (II) first 
acquires the Sync object associated
  @@ -636,59 +640,59 @@
   
                                                        synchronized (getCacheLock())
                                                        {
  -                                                             // This is absolutely 
fundamental: the job must be removed from
  -                                                             // the map in every 
case. If it remains there, the call to
  -                                                             // 
PassivationHelper.unschedule() will cause the corrispondent
  -                                                             // context to be 
reinserted in the cache, and if then is passivated
  -                                                             // we have a context 
without meaning in the cache
  -                                                             
m_passivationJobs.remove(id);
  -
  -                                                             synchronized (this)
  +                                                         // This is absolutely 
fundamental: the job must be removed from
  +                                                         // the map in every case. 
If it remains there, the call to
  +                                                         // 
PassivationHelper.unschedule() will cause the corrispondent
  +                                                         // context to be 
reinserted in the cache, and if then is passivated
  +                                                         // we have a context 
without meaning in the cache
  +                                                         
m_passivationJobs.remove(id);
  +                                                         
  +                                                         synchronized (this)
  +                                                         {
  +                                                             if (!canPassivate(id, 
ctx))
                                                                {
  -                                                                     if 
(!canPassivate(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 cache
  +                                                                 if 
(getCache().peek(id) == null)
  +                                                                 {
  +                                                                     
getCache().insert(id, ctx);
  +                                                                 }
  +                                                                 
  +                                                                 
logPassivationPostponed(id);
  +                                                                 
  +                                                                 return;
  +                                                             }
  +                                                             else
  +                                                             {
  +                                                                 if (!isCancelled())
  +                                                                 {
  +                                                                     try
                                                                        {
  -                                                                             // 
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 cache
  -                                                                             if 
(getCache().peek(id) == null)
  -                                                                             {
  -                                                                                    
 getCache().insert(id, ctx);
  -                                                                             }
  -
  -                                                                             
logPassivationPostponed(id);
  -
  -                                                                             return;
  +                                                                         // If the 
next call throws RemoteException we reinsert
  +                                                                         // the 
bean in the cache; every successive passivation
  +                                                                         // attempt 
will fail. The other policy would have been
  +                                                                         // to 
remove it, but then clients unexpectedly won't
  +                                                                         // find it 
anymore. On the other hand, on the server
  +                                                                         // log it 
is possible to see that passivation for the
  +                                                                         // bean 
failed, and fix it. See EJB 1.1, 6.4.1
  +                                                                         
passivate(ctx);
  +                                                                         executed();
  +                                                                         
removeLock(id);
  +                                                                         
freeContext(ctx);
  +                                                                         
  +                                                                         
logPassivation(id);
                                                                        }
  -                                                                     else
  +                                                                     catch 
(RemoteException x)
                                                                        {
  -                                                                             if 
(!isCancelled())
  -                                                                             {
  -                                                                                    
 try
  -                                                                                    
 {
  -                                                                                    
         // If the next call throws RemoteException we reinsert
  -                                                                                    
         // the bean in the cache; every successive passivation
  -                                                                                    
         // attempt will fail. The other policy would have been
  -                                                                                    
         // to remove it, but then clients unexpectedly won't
  -                                                                                    
         // find it anymore. On the other hand, on the server
  -                                                                                    
         // log it is possible to see that passivation for the
  -                                                                                    
         // bean failed, and fix it. See EJB 1.1, 6.4.1
  -                                                                                    
         passivate(ctx);
  -                                                                                    
         executed();
  -                                                                                    
         removeLock(id);
  -                                                                                    
         freeContext(ctx);
  -
  -                                                                                    
         logPassivation(id);
  -                                                                                    
 }
  -                                                                                    
 catch (RemoteException x)
  -                                                                                    
 {
  -                                                                                    
         // Can't passivate this bean, reinsert it in the cache
  -                                                                                    
         getCache().insert(id, ctx);
  -                                                                                    
         throw x;
  -                                                                                    
 }
  -                                                                             }
  +                                                                         // Can't 
passivate this bean, reinsert it in the cache
  +                                                                         
getCache().insert(id, ctx);
  +                                                                         throw x;
                                                                        }
  +                                                                 }
                                                                }
  +                                                         }
                                                        }
                                                }
                                                catch (InterruptedException ignored) {}
  @@ -729,7 +733,7 @@
                 */
                protected EnterpriseContext unschedule(Object id)
                {
  -                     // I chose not to remove canceled job here because multiple
  +                     // I chose not to remove canceled job here becauses multiple
                        // unscheduling requests can arrive. This way all will be 
served
   
                        // Is the passivation job for id still to be executed ?
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to