Bug 52095 - Inconsistent Javadoc comment in addAppender(Appender) in org.apache.log4j.AsyncAppender
Summary: Inconsistent Javadoc comment in addAppender(Appender) in org.apache.log4j.Asy...
Status: NEW
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-26 20:13 UTC by Shin Hwei Tan
Modified: 2011-10-26 20:13 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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".