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 47547] New: NullPointerException when calling Category.removeAllAppenders()
Date Mon, 20 Jul 2009 07:00:35 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47547

           Summary: NullPointerException when calling
                    Category.removeAllAppenders()
           Product: Log4j
           Version: 1.2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: Appender
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: Michael.Zamir@gmail.com
                CC: Michael.Zamir@gmail.com


The Category.removeAllAppenders() fails, sometime, because of a wrong for-loop
condition, and it throws a NullPointerException

The first for-loop in the Category.removeAllAppenders() looks as following:

for (Enumeration iter = aai.getAllAppenders(); iter.hasMoreElements();) {
          appenders.add(iter.nextElement());
}


But in one of my scenario (BTW I can't understand why it happened only to me),
I got a null 'iter' variable, since the aai.getAllAppenders() may return
'null'.

So the right for-loop should be:

for (Enumeration iter = aai.getAllAppenders(); iter != null &&
iter.hasMoreElements();) {
          appenders.add(iter.nextElement());
}


Michael.

-- 
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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message