fhanik      2004/11/19 11:33:16

  Modified:    modules/cluster/src/share/org/apache/catalina/cluster/session
                        DeltaRequest.java
  Log:
  Synchronized
  
  Revision  Changes    Path
  1.11      +28 -11    
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
  
  Index: DeltaRequest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DeltaRequest.java 26 Oct 2004 14:52:17 -0000      1.10
  +++ DeltaRequest.java 19 Nov 2004 19:33:15 -0000      1.11
  @@ -34,6 +34,9 @@
   
   public class DeltaRequest implements Externalizable {
   
  +    public static org.apache.commons.logging.Log log =
  +        org.apache.commons.logging.LogFactory.getLog( DeltaRequest.class );
  +
       public static final int TYPE_ATTRIBUTE = 0;
       public static final int TYPE_PRINCIPAL = 1;
       public static final int TYPE_ISNEW = 2;
  @@ -91,13 +94,18 @@
           addAction(TYPE_ISNEW,action,NAME_ISNEW,new Boolean(n));
       }
   
  -    protected void addAction(int type,
  +    protected synchronized void addAction(int type,
                                int action,
                                String name,
                                Object value) {
           AttributeInfo info = null;
           if ( this.actionPool.size() > 0 ) {
  -            info = (AttributeInfo)actionPool.removeFirst();
  +            try {
  +                info = (AttributeInfo) actionPool.removeFirst();
  +            }catch ( Exception x ) {
  +                log.error("Unable to remove element:",x);
  +                info = new AttributeInfo(type, action, name, value);
  +            }
               info.init(type,action,name,value);
           } else {
               info = new AttributeInfo(type, action, name, value);
  @@ -119,7 +127,7 @@
           execute(session,true);
       }
   
  -    public void execute(DeltaSession session, boolean notifyListeners) {
  +    public synchronized void execute(DeltaSession session, boolean 
notifyListeners) {
           if ( !this.sessionId.equals( session.getId() ) )
               throw new java.lang.IllegalArgumentException("Session id 
mismatch, not executing the delta request");
           session.access();
  @@ -156,11 +164,15 @@
           session.endAccess();
       }
   
  -    public void reset() {
  +    public synchronized void reset() {
           while ( actions.size() > 0 ) {
  -            AttributeInfo info = (AttributeInfo)actions.removeFirst();
  -            info.recycle();
  -            actionPool.addLast(info);
  +            try {
  +                AttributeInfo info = (AttributeInfo) actions.removeFirst();
  +                info.recycle();
  +                actionPool.addLast(info);
  +            }catch  ( Exception x ) {
  +                log.error("Unable to remove element",x);
  +            }
           }
           actions.clear();
       }
  @@ -178,7 +190,7 @@
           return actions.size();
       }
       
  -    public void clear() {
  +    public synchronized void clear() {
           actions.clear();
           actionPool.clear();
       }
  @@ -200,7 +212,12 @@
           for (int i = 0; i < cnt; i++) {
               AttributeInfo info = null;
               if (this.actionPool.size() > 0) {
  -                info = (AttributeInfo) actionPool.removeFirst();
  +                try {
  +                    info = (AttributeInfo) actionPool.removeFirst();
  +                } catch ( Exception x )  {
  +                    log.error("Unable to remove element",x);
  +                    info = new AttributeInfo(-1,-1,null,null);
  +                }
               }
               else {
                   info = new AttributeInfo(-1,-1,null,null);
  @@ -284,7 +301,7 @@
               return other.getName().equals(this.getName());
           }
           
  -        public void readExternal(java.io.ObjectInput in ) throws 
java.io.IOException,
  +        public synchronized void readExternal(java.io.ObjectInput in ) 
throws java.io.IOException,
               java.lang.ClassNotFoundException {
               //type - int
               //action - int
  @@ -296,7 +313,7 @@
               value = in.readObject();
           }
   
  -        public void writeExternal(java.io.ObjectOutput out) throws java.io.
  +        public synchronized void writeExternal(java.io.ObjectOutput out) 
throws java.io.
               IOException {
               //type - int
               //action - int
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to