Bug 52095

Summary: Inconsistent Javadoc comment in addAppender(Appender) in org.apache.log4j.AsyncAppender
Product: Log4j - Now in Jira Reporter: Shin Hwei Tan <stan6>
Component: AppenderAssignee: log4j-dev <log4j-dev>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Shin Hwei Tan 2011-10-26 20:13:05 UTC
The Javadoc comment below states that the parameter appender "may not be null":
  /**
   * Add appender.
   *
   * @param newAppender appender to add, may not be null.
   */
  public void addAppender(final Appender newAppender) {
    synchronized (appenders) {
      appenders.addAppender(newAppender);
    }
  }

However, the called method "org.apache.log4j.helpers.AppenderAttachableImpl#addAppender(Appender)" has an explicit check for "null" and will ignore it, returning normally without any exception being thrown.  Also, the Javadoc for the called method does not mention "null".

Suggested Fixes:
1. Make the Javadoc in "org.apache.log4j.AsyncAppender#addAppender(Appender)" consistent with the Javadoc in "org.apache.log4j.helpers.AppenderAttachableImpl#addAppender(Appender)" (note that the second "in" should be "it" in both):
  /**
   * Attach an appender. If the appender is already in the list in [sic] won't be added.
   *
   * @param newAppender appender to add
   */
  public void addAppender(final Appender newAppender) {
or
2. Simply remove ", may not be null" from the Javadoc in "org.apache.log4j.AsyncAppender#addAppender(Appender)".
or
3. Change ", may not be null" to ", null will be ignored".