logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: jakarta-log4j/src/java/org/apache/log4j AppenderSkeleton.java
Date Wed, 16 Oct 2002 13:42:37 GMT
ceki        2002/10/16 06:42:37

  Modified:    src/java/org/apache/log4j AppenderSkeleton.java
  Log:
  Added appedner reentrancy support.
  
  Revision  Changes    Path
  1.21      +26 -11    jakarta-log4j/src/java/org/apache/log4j/AppenderSkeleton.java
  
  Index: AppenderSkeleton.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/AppenderSkeleton.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AppenderSkeleton.java	9 Oct 2002 22:50:01 -0000	1.20
  +++ AppenderSkeleton.java	16 Oct 2002 13:42:37 -0000	1.21
  @@ -54,6 +54,10 @@
      */
     protected boolean closed = false;
   
  +  /** The guard prevents an appender from repeatedly calling its own
  +      doAppend method. */
  +  private boolean guard = false;
  +
   
     /**
        Derived appenders should override this method if option structure
  @@ -203,22 +207,33 @@
         return;
       }
       
  -    if(!isAsSevereAsThreshold(event.getLevel())) {
  +    // prevent re-entry
  +    if(guard) {
         return;
  -    }
  +     }
   
  -    Filter f = this.headFilter;
  -    
  +    try {
  +      guard = true;
  +      
  +      if(!isAsSevereAsThreshold(event.getLevel())) {
  +	return;
  +      }
  +      
  +      Filter f = this.headFilter;
  +      
       FILTER_LOOP:
  -    while(f != null) {
  -      switch(f.decide(event)) {
  -      case Filter.DENY: return;
  -      case Filter.ACCEPT: break FILTER_LOOP;
  -      case Filter.NEUTRAL: f = f.next;
  +      while(f != null) {
  +	switch(f.decide(event)) {
  +	case Filter.DENY: return;
  +	case Filter.ACCEPT: break FILTER_LOOP;
  +	case Filter.NEUTRAL: f = f.next;
  +	}
         }
  +      
  +      this.append(event);    
  +    } finally {
  +      guard = false;
       }
  -    
  -    this.append(event);    
     }
   
     /** 
  
  
  

--
To unsubscribe, e-mail:   <mailto:log4j-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-dev-help@jakarta.apache.org>


Mime
View raw message