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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to