logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31003] New: - RollingFileAppender, if removed can cause null pointer exceptions
Date Wed, 01 Sep 2004 20:07:23 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31003>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31003

RollingFileAppender, if removed can cause null pointer exceptions

           Summary: RollingFileAppender, if removed can cause null pointer
                    exceptions
           Product: Log4j
           Version: 1.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Appender
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: eross@m-qube.com


Steps to reproduce:

    Layout layout = new PatternLayout(this.logfileLayout);
    RollingFileAppender rfa = new RollingFileAppender(layout, filename, true);
    Logger.getRootLogger().addAppender(rfa);
    Logger.getRootLogger().removeAllAppenders();
    rfa.rollOver();

Results:

    [junit] java.lang.NullPointerException
    [junit]     at
org.apache.log4j.RollingFileAppender.rollOver(RollingFileAppender.java:112)

Cause:

cw is null:

src/java/org/apache/log4j/RollingFileAppender.java

  public // synchronization not necessary since doAppend is alreasy synched
  void rollOver() {
    File target;
    File file;
                                                                               
                                                                               
    LogLog.debug("rolling over count=" + ((CountingQuietWriter) qw).getCount());
    LogLog.debug("maxBackupIndex="+maxBackupIndex);
                                                                               
                                                                               

Suggestion:

Either do nothing if the appender is closed or throw a better exception.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message