|
|
6d9473 |
From 992b95828e2efe54f30d81c1418e997215ed22b5 Mon Sep 17 00:00:00 2001
|
|
|
6d9473 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
6d9473 |
Date: Wed, 29 Oct 2014 14:07:10 +0100
|
|
|
6d9473 |
Subject: [PATCH] Fix a deadlock in RemoteTest
|
|
|
6d9473 |
|
|
|
6d9473 |
Related to #42
|
|
|
6d9473 |
---
|
|
|
6d9473 |
test/CMakeLists.txt | 1 +
|
|
|
6d9473 |
test/RemoteTest.java | 12 ++++++++++--
|
|
|
6d9473 |
test/outputs/run_remote.log.in | 4 ++--
|
|
|
6d9473 |
3 files changed, 13 insertions(+), 4 deletions(-)
|
|
|
6d9473 |
|
|
|
6d9473 |
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
|
|
|
6d9473 |
index 4e69049..5bb2b2d 100644
|
|
|
6d9473 |
--- a/test/CMakeLists.txt
|
|
|
6d9473 |
+++ b/test/CMakeLists.txt
|
|
|
6d9473 |
@@ -106,6 +106,7 @@ function(_add_test_target target_name)
|
|
|
6d9473 |
add_custom_target(
|
|
|
6d9473 |
${target_name}
|
|
|
6d9473 |
${pre_command}
|
|
|
6d9473 |
+# -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n + jdb -attach 8001
|
|
|
6d9473 |
COMMAND LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src ${Java_JAVA_EXECUTABLE} -agentlib:${AGENT_NAME}="${agent_options},abrt=$$ABRT_ENABLED,output=${target_name}.log" ${java_params}
|
|
|
6d9473 |
DEPENDS AbrtChecker ${depends}
|
|
|
6d9473 |
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
6d9473 |
diff --git a/test/RemoteTest.java b/test/RemoteTest.java
|
|
|
6d9473 |
index 6071f8e..040384f 100644
|
|
|
6d9473 |
--- a/test/RemoteTest.java
|
|
|
6d9473 |
+++ b/test/RemoteTest.java
|
|
|
6d9473 |
@@ -73,11 +73,19 @@ public class RemoteTest {
|
|
|
6d9473 |
server.setExecutor(null); // creates a default executor
|
|
|
6d9473 |
server.start();
|
|
|
6d9473 |
|
|
|
6d9473 |
+ /* Download the jar in order to fully intialize the second thread.
|
|
|
6d9473 |
+ * Since Java-1.8 HttpExchange.sendResponseHeaders() adds 'Date' header
|
|
|
6d9473 |
+ * with value formated according to locale. Getting the locale leads to
|
|
|
6d9473 |
+ * loading of some other class which results in a deadlock.
|
|
|
6d9473 |
+ */
|
|
|
6d9473 |
+ URL remoteJarUrl = new URL("http://localhost:54321/JarTest.jar");
|
|
|
6d9473 |
+ InputStream input = remoteJarUrl.openStream();
|
|
|
6d9473 |
+ input.close();
|
|
|
6d9473 |
+
|
|
|
6d9473 |
try {
|
|
|
6d9473 |
Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
|
|
|
6d9473 |
method.setAccessible(true);
|
|
|
6d9473 |
- method.invoke(ClassLoader.getSystemClassLoader(), new Object[]{new URL("http://localhost:54321/JarTest.jar")});
|
|
|
6d9473 |
-
|
|
|
6d9473 |
+ method.invoke(ClassLoader.getSystemClassLoader(), new Object[]{remoteJarUrl});
|
|
|
6d9473 |
/* Loaded these classes into cache. */
|
|
|
6d9473 |
final String needed[] = {"SimpleTest", "ThreadUncaughtException", "ThreadCaughtException"};
|
|
|
6d9473 |
for (String requiredClass : needed) {
|
|
|
6d9473 |
diff --git a/test/outputs/run_remote.log.in b/test/outputs/run_remote.log.in
|
|
|
6d9473 |
index 90f5db7..aeb7890 100644
|
|
|
6d9473 |
--- a/test/outputs/run_remote.log.in
|
|
|
6d9473 |
+++ b/test/outputs/run_remote.log.in
|
|
|
6d9473 |
@@ -7,7 +7,7 @@ Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 42
|
|
|
6d9473 |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/NativeMethodAccessorImpl.class]
|
|
|
6d9473 |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/DelegatingMethodAccessorImpl.class]
|
|
|
6d9473 |
at java.lang.reflect.Method.invoke(Method.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/lang/reflect/Method.class]
|
|
|
6d9473 |
- at RemoteTest.main(RemoteTest.java:102) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
|
|
|
6d9473 |
+ at RemoteTest.main(RemoteTest.java:110) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
|
|
|
6d9473 |
executable: @CMAKE_BINARY_DIR@/test/RemoteTest.class
|
|
|
6d9473 |
Uncaught exception java.lang.NullPointerException in method SimpleTest.throwNullPointerException()
|
|
|
6d9473 |
Exception in thread "main" java.lang.NullPointerException
|
|
|
6d9473 |
@@ -17,5 +17,5 @@ Exception in thread "main" java.lang.NullPointerException
|
|
|
6d9473 |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/NativeMethodAccessorImpl.class]
|
|
|
6d9473 |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/DelegatingMethodAccessorImpl.class]
|
|
|
6d9473 |
at java.lang.reflect.Method.invoke(Method.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/lang/reflect/Method.class]
|
|
|
6d9473 |
- at RemoteTest.main(RemoteTest.java:104) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
|
|
|
6d9473 |
+ at RemoteTest.main(RemoteTest.java:112) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
|
|
|
6d9473 |
executable: @CMAKE_BINARY_DIR@/test/RemoteTest.class
|
|
|
6d9473 |
--
|
|
|
6d9473 |
1.8.3.1
|
|
|
6d9473 |
|