diff options
author | xuelei <none@none> | 2013-06-18 18:50:13 -0700 |
---|---|---|
committer | xuelei <none@none> | 2013-06-18 18:50:13 -0700 |
commit | 99039a30c310ce905b3fcbb3339c05ce9c12831e (patch) | |
tree | 208d10158da093f844a216f757b3ee3b45e6e53b | |
parent | e70ac0c2ea77f180131e6f266925d7a720b40701 (diff) |
8000456: Add programmatic deadlock detection in SSLEngineDeadlock
Reviewed-by: wetmore
-rw-r--r-- | test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineDeadlock.java | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineDeadlock.java b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineDeadlock.java index 1de0ab3bc..0522226d9 100644 --- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineDeadlock.java +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineDeadlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -21,15 +21,14 @@ * questions. */ +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + /* * @test * @bug 6492872 * @summary Deadlock in SSLEngine * @run main/othervm SSLEngineDeadlock - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. - * * @author Brad R. Wetmore */ @@ -74,6 +73,7 @@ import javax.net.ssl.SSLEngineResult.*; import java.io.*; import java.security.*; import java.nio.*; +import java.lang.management.*; public class SSLEngineDeadlock { @@ -144,6 +144,8 @@ public class SSLEngineDeadlock { } SSLEngineDeadlock test = new SSLEngineDeadlock(); test.runTest(); + + detectDeadLock(); } System.out.println("Test Passed."); } @@ -361,6 +363,22 @@ public class SSLEngineDeadlock { } /* + * Detect dead lock + */ + private static void detectDeadLock() throws Exception { + ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); + long[] threadIds = threadBean.findDeadlockedThreads(); + if (threadIds != null && threadIds.length != 0) { + for (long id : threadIds) { + ThreadInfo info = + threadBean.getThreadInfo(id, Integer.MAX_VALUE); + System.out.println("Deadlocked ThreadInfo: " + info); + } + throw new Exception("Found Deadlock!"); + } + } + + /* * Logging code */ private static boolean resultOnce = true; |