ASF Bugzilla – Attachment 9633 Details for
Bug 24159
Log4J can create deadlock conditions (concurrent package donation)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Diffs for AppenderSkeleton and WriterAppender
fix-appender.patch (text/plain), 3.03 KB, created by
Elias Ross
on 2003-12-18 21:13:21 UTC
(
hide
)
Description:
Diffs for AppenderSkeleton and WriterAppender
Filename:
MIME Type:
Creator:
Elias Ross
Created:
2003-12-18 21:13:21 UTC
Size:
3.03 KB
patch
obsolete
>--- ./src/java/org/apache/log4j/AppenderSkeleton.java.orig 2003-12-18 12:50:52.000000000 -0800 >+++ ./src/java/org/apache/log4j/AppenderSkeleton.java 2003-12-18 13:05:27.000000000 -0800 >@@ -193,34 +193,45 @@ > /** > * This method performs threshold checks and invokes filters before > * delegating actual logging to the subclasses specific {@link > * AppenderSkeleton#append} method. > * */ >- public >- synchronized >+ public final > void doAppend(LoggingEvent event) { >+ synchronized (this) { >+ if (!canAppend(event)) return; >+ } >+ this.append(event); >+ } >+ >+ /** >+ Subclasses of <code>AppenderSkeleton</code> may wish to extend this >+ method to check if a statement should be logged. >+ This method is called synchronized on the appender. >+ */ >+ protected boolean canAppend(LoggingEvent event) { > if(closed) { > LogLog.error("Attempted to append to closed appender named ["+name+"]."); >- return; >+ return false; > } > > if(!isAsSevereAsThreshold(event.getLevel())) { >- return; >+ return false; > } > > Filter f = this.headFilter; > > FILTER_LOOP: > while(f != null) { > switch(f.decide(event)) { >- case Filter.DENY: return; >+ case Filter.DENY: return false; > case Filter.ACCEPT: break FILTER_LOOP; > case Filter.NEUTRAL: f = f.next; > } > } > >- this.append(event); >+ return true; > } > > /** > Set the {@link ErrorHandler} for this Appender. > @since 0.9.0 >--- ./src/java/org/apache/log4j/WriterAppender.java.orig 2003-12-18 12:53:13.000000000 -0800 >+++ ./src/java/org/apache/log4j/WriterAppender.java 2003-12-18 13:10:10.000000000 -0800 >@@ -118,10 +118,14 @@ > public > void activateOptions() { > } > > >+ protected synchronized boolean canAppend(LoggingEvent event) { >+ return super.canAppend(event) && checkEntryConditions(); >+ } >+ > /** > This method is called by the {@link AppenderSkeleton#doAppend} > method. > > <p>If the output stream exists and is writable then write a log >@@ -142,13 +146,10 @@ > // - filter > // - append(); > // - checkEntryConditions(); > // - subAppend(); > >- if(!checkEntryConditions()) { >- return; >- } > subAppend(event); > } > > /** > This method determines if there is a sense in attempting to append. >@@ -287,22 +288,29 @@ > override this method. > > @since 0.9.0 */ > protected > void subAppend(LoggingEvent event) { >- this.qw.write(this.layout.format(event)); >+ String fe = this.layout.format(event); >+ synchronized (this) { >+ if (!canAppend(event)) return; >+ this.qw.write(fe); >+ } > > if(layout.ignoresThrowable()) { > String[] s = event.getThrowableStrRep(); > if (s != null) { > int len = s.length; > for(int i = 0; i < len; i++) { >+ synchronized (this) { >+ if (!canAppend(event)) return; > this.qw.write(s[i]); > this.qw.write(Layout.LINE_SEP); > } > } > } >+ } > > if(this.immediateFlush) { > this.qw.flush(); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 24159
:
9633
|
9634
|
9635
|
12840
|
17133
|
17612
|
17613
|
18997
|
18998
|
19004