https://issues.apache.org/bugzilla/show_bug.cgi?id=46539

           Summary: The QuietWriter class does not live up to its published
                    contract
           Product: Log4j
           Version: 1.2
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Keywords: JDK1.5
          Severity: major
          Priority: P2
         Component: Other
        AssignedTo: [email protected]
        ReportedBy: [email protected]


The QuietWriter class (in org.apache.log4j.helpers) does not live up to its
published contract.  The javadocs says that "QuietWriter does not throw
exceptions when things go wrong...", however, it will allow Runtime Exceptions
to bubble up.

I propose that QuietWriter catch Exception (not just IOException) to fullfil
its contract.

This is a real problem running log4j with java 1.5 and the assorted
CharsetEncoder state problems.  

java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING
        at
java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:941)
        at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:537)
        at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:384)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:146)
        at java.io.OutputStreamWriter.write(OutputStreamWriter.java:204)
        at java.io.Writer.write(Writer.java:126)
        at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:47)
        at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:301)
        at
org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:358)
        at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
        at
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
        at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
        at org.apache.log4j.AsyncAppender.append(AsyncAppender.java:87)
        at
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
        at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
        at org.apache.log4j.Category.callAppenders(Category.java:203)
        at org.apache.log4j.Category.forcedLog(Category.java:388)
        at org.apache.log4j.Category.log(Category.java:853)
        at
org.apache.commons.logging.impl.Log4JLogger.warn(Log4JLogger.java:157)

In this example The CharsetEncoder threw an IllegalStateException causing the
AsyncAppender's Dispatcher thread to die.  Now the appender is synchronous but
another IllegalStateException bubbled out of the application code.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to