JDK-6537552 : JConsole get NPE if TMP directory doesn't exist
  • Type: Bug
  • Component: tools
  • Sub-Component: jconsole
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-03-22
  • Updated: 2010-07-29
  • Resolved: 2007-03-22
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
If you set the TMP environment variable to point to a non existing directory, jconsole will throw a NPE whenever it needs to show available VMs.
Tested with both 1.5.0_10 and 1.5.0_06

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On windows
set TMP=c:\doesNotExist
jconsole

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An error message would be nice, or at least being able to show the Local/Remote vm dialog.
ACTUAL -
The dialog is never shown, instead you get a stackTrace

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at sun.jvmstat.perfdata.monitor.protocol.local.LocalVmManager.activeVms(LocalVmManager.java:127)
        at sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider.activeVms(MonitoredHostProvider.java:133)
        at sun.tools.jconsole.ConnectDialog$ManagedVmTableModel.getManagedVirtualMachines(ConnectDialog.java:528)
        at sun.tools.jconsole.ConnectDialog$ManagedVmTableModel.refresh(ConnectDialog.java:511)
        at sun.tools.jconsole.ConnectDialog$ManagedVmTableModel.<init>(ConnectDialog.java:502)
        at sun.tools.jconsole.ConnectDialog.<init>(ConnectDialog.java:139)
        at sun.tools.jconsole.JConsole.showConnectDialog(JConsole.java:571)
        at sun.tools.jconsole.JConsole.access$100(JConsole.java:34)
        at sun.tools.jconsole.JConsole$4.run(JConsole.java:702)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

REPRODUCIBILITY :
This bug can be reproduced always.

Comments
SUGGESTED FIX Check for non-null array before iterating in the for loop.
22-03-2007

EVALUATION When the TMP environment variable is set to a non-existing directory the array of user temporary directories computed by the method sun.jvmstat.perfdata.monitor.protocol.local.LocalVmManager.activeVms() is null and thus calling dirs.length fires a NullPointerException.
22-03-2007

WORK AROUND Set the TMP environment variable to a read-write NTFS directory.
22-03-2007