From f2b9a3e5b96a9f28ce69da05e58c03310794a7f7 Mon Sep 17 00:00:00 2001 From: Gary Adams Date: Thu, 13 Sep 2018 07:54:38 -0400 Subject: [PATCH] 8210252: com/sun/jdi/DebuggerThreadTest.java fails with NPE Reviewed-by: cjplummer, sspitsyn --- test/jdk/com/sun/jdi/DebuggerThreadTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/jdk/com/sun/jdi/DebuggerThreadTest.java b/test/jdk/com/sun/jdi/DebuggerThreadTest.java index 496f023539a..45cfb3c15b0 100644 --- a/test/jdk/com/sun/jdi/DebuggerThreadTest.java +++ b/test/jdk/com/sun/jdi/DebuggerThreadTest.java @@ -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 @@ public class DebuggerThreadTest extends TestScaffold { * 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 @@ public class DebuggerThreadTest extends TestScaffold { 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 = ""; + finishedThreads++ ; + } else { + groupName = tga.getName(); + } System.out.println("Thread [" + i + "] group = '" + groupName + @@ -89,7 +97,10 @@ public class DebuggerThreadTest extends TestScaffold { failure("FAIL: non-daemon thread '" + t.getName() + "' found in ThreadGroup '" + groupName + "'"); } - + } + if (finishedThreads > 0 ) { + failure("FAIL: " + finishedThreads + + " threads completed while VM suspended."); } }