JDK-8170487 : jvmstat fails to send updates to listener on unchecked exception
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 8u111
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2016-11-29
  • Updated: 2021-07-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Users using the jvmstat API might register a VmListener in order to get notified on monitor updates (fireMonitorsUpdatedEvents() in LocalMonitoredVm.java).

Internally a Timer is used to notify listeners on a given interval. However, when a NotifierTask throws an unchecked exception, the Timer dies, preventing any further updates for any monitors.

One such instance where a runtime exception might occur in NotifierTask is when a JVM is currently active waiting for a debugger to attach.

This could be a potential fix:
diff --git a/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java b/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java
--- a/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java
+++ b/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java
@@ -202,6 +202,11 @@
                 System.err.println("Exception updating monitors for "
                                    + getVmIdentifier());
                 e.printStackTrace();
+            } catch (Throwable e) {
+                // XXX: use logging api
+                System.err.println("Exception updating monitors for "
+                                   + getVmIdentifier());
+                e.printStackTrace();
             }
         }
     }