8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException
authorcoleenp
Thu, 11 Sep 2014 10:46:32 -0400
changeset 26687 eb6c5d0d1d6b
parent 26686 d7bc560b0ee9
child 26688 bb0cdd873e51
8055145: [TESTBUG] runtime/7158988/FieldMonitor.java fails with VMDisconnectedException Summary: Exclude this test on JPRT and make it trivially pass if it gets a disconnected exception (which seems rare) Reviewed-by: gtriantafill, sspitsyn, ctornqvi
hotspot/test/TEST.groups
hotspot/test/runtime/7158988/FieldMonitor.java
--- a/hotspot/test/TEST.groups	Thu Sep 11 03:13:29 2014 -0700
+++ b/hotspot/test/TEST.groups	Thu Sep 11 10:46:32 2014 -0400
@@ -342,7 +342,8 @@
  -runtime/Unsafe/RangeCheck.java \
  -runtime/SharedArchiveFile/CdsSameObjectAlignment.java \
  -runtime/SharedArchiveFile/DefaultUseWithClient.java \
- -runtime/Thread/CancellableThreadTest.java
+ -runtime/Thread/CancellableThreadTest.java \
+ -runtime/runtime/7158988/FieldMonitor.java
 
 hotspot_runtime_closed = \
   sanity/ExecuteInternalVMTests.java
--- a/hotspot/test/runtime/7158988/FieldMonitor.java	Thu Sep 11 03:13:29 2014 -0700
+++ b/hotspot/test/runtime/7158988/FieldMonitor.java	Thu Sep 11 10:46:32 2014 -0400
@@ -26,7 +26,6 @@
  * @bug 7158988
  * @key regression
  * @summary verify jvm does not crash while debugging
- * @ignore 8055145
  * @run compile TestPostFieldModification.java
  * @run main/othervm FieldMonitor
  * @author axel.siebenborn@sap.com
@@ -91,35 +90,41 @@
     boolean connected = true;
     int watched = 0;
     while (connected) {
-      EventSet eventSet = eventQueue.remove();
-      for (Event event : eventSet) {
-        System.out.println("FieldMonitor-main receives: "+event);
-        if (event instanceof VMStartEvent) {
-          addClassWatch(vm);
-        } else if (event instanceof VMDeathEvent
-            || event instanceof VMDisconnectEvent) {
-          // exit
-          connected = false;
-        } else if (event instanceof ClassPrepareEvent) {
-          // watch field on loaded class
-          System.out.println("ClassPrepareEvent");
-          ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event;
-          ReferenceType refType = classPrepEvent
-              .referenceType();
-          addFieldWatch(vm, refType);
-        } else if (event instanceof ModificationWatchpointEvent) {
-          watched++;
-          System.out.println("sleep for 500 ms");
-          Thread.sleep(500);
+        try {
+            EventSet eventSet = eventQueue.remove();
+            for (Event event : eventSet) {
+              System.out.println("FieldMonitor-main receives: "+event);
+              if (event instanceof VMStartEvent) {
+                addClassWatch(vm);
+              } else if (event instanceof VMDeathEvent
+                  || event instanceof VMDisconnectEvent) {
+                // exit
+                connected = false;
+              } else if (event instanceof ClassPrepareEvent) {
+                // watch field on loaded class
+                System.out.println("ClassPrepareEvent");
+                ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event;
+                ReferenceType refType = classPrepEvent
+                    .referenceType();
+                addFieldWatch(vm, refType);
+              } else if (event instanceof ModificationWatchpointEvent) {
+                watched++;
+                System.out.println("sleep for 500 ms");
+                Thread.sleep(500);
 
-          ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event;
-          System.out.println("old="
-              + modEvent.valueCurrent());
-          System.out.println("new=" + modEvent.valueToBe());
+                ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event;
+                System.out.println("old="
+                    + modEvent.valueCurrent());
+                System.out.println("new=" + modEvent.valueToBe());
+              }
+            }
+            System.out.println("resume...");
+            eventSet.resume();
+        } catch (com.sun.jdi.VMDisconnectedException exc) {
+            // Guess this means it's not connected anymore,
+            // sometimes this happens and everything else hangs, just return.
+            return;
         }
-      }
-      System.out.println("resume...");
-      eventSet.resume();
     }
     // Shutdown begins when event thread terminates
     try {