The main ASF Bugzilla instance will be unavailable for 4 hours starting 19.00 UTC 2016-10-29 for an upgrade to 5.0.3
Bug 47547 - NullPointerException when calling Category.removeAllAppenders()
NullPointerException when calling Category.removeAllAppenders()
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender
All All
: P2 normal
: ---
Assigned To: log4j-dev
: PatchAvailable
Depends on:
  Show dependency tree
Reported: 2009-07-20 00:00 UTC by Michael
Modified: 2009-10-10 19:39 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Michael 2009-07-20 00:00:34 UTC
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();) {

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();) {

Comment 1 Curt Arnold 2009-10-10 19:39:37 UTC
Fix committed in rev 824000.

There were several checks for getAllAppenders() returning null, just not in removeAllAppenders.