提交 6bdea27d 编写于 作者: X xuelei

8000456: Add programmatic deadlock detection in SSLEngineDeadlock

Reviewed-by: wetmore
上级 bcd4319e
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -21,15 +21,14 @@ ...@@ -21,15 +21,14 @@
* questions. * questions.
*/ */
// SunJSSE does not support dynamic system properties, no way to re-use
// system properties in samevm/agentvm mode.
/* /*
* @test * @test
* @bug 6492872 * @bug 6492872
* @summary Deadlock in SSLEngine * @summary Deadlock in SSLEngine
* @run main/othervm SSLEngineDeadlock * @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 * @author Brad R. Wetmore
*/ */
...@@ -74,6 +73,7 @@ import javax.net.ssl.SSLEngineResult.*; ...@@ -74,6 +73,7 @@ import javax.net.ssl.SSLEngineResult.*;
import java.io.*; import java.io.*;
import java.security.*; import java.security.*;
import java.nio.*; import java.nio.*;
import java.lang.management.*;
public class SSLEngineDeadlock { public class SSLEngineDeadlock {
...@@ -144,6 +144,8 @@ public class SSLEngineDeadlock { ...@@ -144,6 +144,8 @@ public class SSLEngineDeadlock {
} }
SSLEngineDeadlock test = new SSLEngineDeadlock(); SSLEngineDeadlock test = new SSLEngineDeadlock();
test.runTest(); test.runTest();
detectDeadLock();
} }
System.out.println("Test Passed."); System.out.println("Test Passed.");
} }
...@@ -360,6 +362,22 @@ public class SSLEngineDeadlock { ...@@ -360,6 +362,22 @@ public class SSLEngineDeadlock {
b.limit(b.capacity()); b.limit(b.capacity());
} }
/*
* 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 * Logging code
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册