fhanik      2004/11/19 09:20:02

  Modified:    modules/cluster/src/share/org/apache/catalina/cluster/session
                        Tag: TOMCAT_5_0 DeltaRequest.java
  Log:
  Fixed synchronization issues, since its getting more common that people still 
have to have multiple threads accessing their session
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.1   +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.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- DeltaRequest.java 27 Feb 2004 14:58:56 -0000      1.7
  +++ DeltaRequest.java 19 Nov 2004 17:20:02 -0000      1.7.2.1
  @@ -35,6 +35,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;
  @@ -93,13 +96,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("Error removing actions:",x);
  +                info = new AttributeInfo(type, action, name, value);
  +            }
               info.init(type,action,name,value);
           } else {
               info = new AttributeInfo(type, action, name, value);
  @@ -111,7 +119,7 @@
           actions.addLast(info);
       }
   
  -    public void execute(DeltaSession session) {
  +    public synchronized void execute(DeltaSession session) {
           if ( !this.sessionId.equals( session.getId() ) )
               throw new java.lang.IllegalArgumentException("Session id 
mismatch, not executing the delta request");
           session.access();
  @@ -148,11 +156,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("Error removing actions:",x);
  +            }
           }
           actions.clear();
       }
  @@ -170,12 +182,12 @@
           return actions.size();
       }
       
  -    public void clear() {
  +    public synchronized void clear() {
           actions.clear();
           actionPool.clear();
       }
       
  -    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 {
           //sessionId - String
           //recordAll - boolean
  @@ -192,7 +204,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("Error removing actions:", x);
  +                    info = new AttributeInfo( -1, -1, null, null);
  +                }
               }
               else {
                   info = new AttributeInfo(-1,-1,null,null);
  @@ -204,7 +221,7 @@
           
   
   
  -    public void writeExternal(java.io.ObjectOutput out ) throws 
java.io.IOException {
  +    public synchronized void writeExternal(java.io.ObjectOutput out ) throws 
java.io.IOException {
           //sessionId - String
           //recordAll - boolean
           //size - int
  
  
  

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

Reply via email to