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