8210252: com/sun/jdi/DebuggerThreadTest.java fails with NPE
authorgadams
Thu, 13 Sep 2018 07:54:38 -0400
changeset 51732 dc68380e6497
parent 51731 8745f8f1b0f8
child 51733 a929ad0569ee
8210252: com/sun/jdi/DebuggerThreadTest.java fails with NPE Reviewed-by: cjplummer, sspitsyn
test/jdk/com/sun/jdi/DebuggerThreadTest.java
--- a/test/jdk/com/sun/jdi/DebuggerThreadTest.java	Thu Sep 13 15:27:21 2018 -0700
+++ b/test/jdk/com/sun/jdi/DebuggerThreadTest.java	Thu Sep 13 07:54:38 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,6 +66,7 @@
      * Move to top ThreadGroup and dump all threads.
      */
     public void dumpThreads() {
+        int finishedThreads = 0;
         ThreadGroup tg = Thread.currentThread().getThreadGroup();
         ThreadGroup parent = tg.getParent();
         while (parent != null) {
@@ -77,7 +78,14 @@
         int gotThreads = tg.enumerate(list, true);
         for (int i = 0; i < Math.min(gotThreads, list.length); i++){
             Thread t = list[i];
-            String groupName = t.getThreadGroup().getName();
+            ThreadGroup tga = t.getThreadGroup();
+            String groupName;
+            if (tga == null) {
+                groupName = "<completed>";
+                finishedThreads++ ;
+            } else {
+                groupName = tga.getName();
+            }
 
             System.out.println("Thread [" + i + "] group = '" +
                                groupName +
@@ -89,7 +97,10 @@
                 failure("FAIL: non-daemon thread '" + t.getName() +
                         "' found in ThreadGroup '" + groupName + "'");
             }
-
+        }
+        if (finishedThreads > 0 ) {
+            failure("FAIL: " + finishedThreads +
+                    " threads completed while VM suspended.");
         }
     }