FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Redhat, kernel 2.4.21-27.0.1.ELsmp
A DESCRIPTION OF THE PROBLEM :
When java.lang.management.ThreadMXBean.dumpAllThreads() is called, it can call Thread.getName() when the "name" field is null. This causes a NullPointerException, and the dumpAllThreads() call fails. It has only happened once at webserver startup when the machine is very busy and lots of threads are being initialized, but it killed the thread since the exception was unexpected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Not sure how to reproduce it reliably, but it would probably involve creating threads while calling dumpAllThreads() repeatedly while the machine is very heavily loaded.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Eventually, a thread with a null name would be caught.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "PeriodicThreadDumper" java.lang.NullPointerException
at java.lang.String.<init>(String.java:176)
at java.lang.String.valueOf(String.java:2841)
at java.lang.Thread.getName(Thread.java:1061)
at java.lang.management.ThreadInfo.initialize(ThreadInfo.java:205)
at java.lang.management.ThreadInfo.<init>(ThreadInfo.java:177)
at sun.management.ThreadImpl.dumpThreads0(Native Method)
at sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:374)
at jlib.ThreadDumper16.captureThreadData(ThreadDumper16.java:56)
at jlib.PeriodicThreadDumper.run(PeriodicThreadDumper.java:51)
at java.lang.Thread.run(Thread.java:619)
REPRODUCIBILITY :
This bug can be reproduced rarely.
CUSTOMER SUBMITTED WORKAROUND :
Catch the exception and call the method again (either dumpAllThreads or getName as the case may be). In my case, I'll retry calling dumpAllThreads