Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a deadlock in RemoteTest
Related to #42
  • Loading branch information
Jakub Filak committed Oct 29, 2014
1 parent af03cf8 commit 2a12dd2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Expand Up @@ -111,6 +111,7 @@ function(_add_test_target target_name)
add_custom_target(
${target_name}
${pre_command}
# -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n + jdb -attach 8001
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}
DEPENDS AbrtChecker ${depends}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand Down
12 changes: 10 additions & 2 deletions test/RemoteTest.java
Expand Up @@ -73,11 +73,19 @@ else if (args.length > 2) {
server.setExecutor(null); // creates a default executor
server.start();

/* Download the jar in order to fully intialize the second thread.
* Since Java-1.8 HttpExchange.sendResponseHeaders() adds 'Date' header
* with value formated according to locale. Getting the locale leads to
* loading of some other class which results in a deadlock.
*/
URL remoteJarUrl = new URL("http://localhost:54321/JarTest.jar");
InputStream input = remoteJarUrl.openStream();
input.close();

try {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
method.setAccessible(true);
method.invoke(ClassLoader.getSystemClassLoader(), new Object[]{new URL("http://localhost:54321/JarTest.jar")});

method.invoke(ClassLoader.getSystemClassLoader(), new Object[]{remoteJarUrl});
/* Loaded these classes into cache. */
final String needed[] = {"SimpleTest", "ThreadUncaughtException", "ThreadCaughtException"};
for (String requiredClass : needed) {
Expand Down
4 changes: 2 additions & 2 deletions test/outputs/run_remote.log.in
Expand Up @@ -7,7 +7,7 @@ Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 42
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/NativeMethodAccessorImpl.class]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/DelegatingMethodAccessorImpl.class]
at java.lang.reflect.Method.invoke(Method.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/lang/reflect/Method.class]
at RemoteTest.main(RemoteTest.java:102) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
at RemoteTest.main(RemoteTest.java:110) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
executable: @CMAKE_BINARY_DIR@/test/RemoteTest.class
Uncaught exception java.lang.NullPointerException in method SimpleTest.throwNullPointerException()
Exception in thread "main" java.lang.NullPointerException
Expand All @@ -17,5 +17,5 @@ Exception in thread "main" java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/NativeMethodAccessorImpl.class]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/reflect/DelegatingMethodAccessorImpl.class]
at java.lang.reflect.Method.invoke(Method.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/lang/reflect/Method.class]
at RemoteTest.main(RemoteTest.java:104) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
at RemoteTest.main(RemoteTest.java:112) [file:@CMAKE_BINARY_DIR@/test/RemoteTest.class]
executable: @CMAKE_BINARY_DIR@/test/RemoteTest.class

0 comments on commit 2a12dd2

Please sign in to comment.