Skip to content

Commit

Permalink
Add test from JRUBY-1559, which has been fixed since Bill installed h…
Browse files Browse the repository at this point in the history
…is ObjectProxyCache.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7544 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed Aug 26, 2008
1 parent 03d6384 commit 9e0dd63
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/jruby_index
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ test_math
test_nkf
test_java_accessible_object
test_java_extension
test_java_wrapper_deadlock
test_jruby_internals
compiler/test_jrubyc
test_launching_by_shell_script
Expand Down Expand Up @@ -84,4 +85,4 @@ test_jruby_object_input_stream
test_jar_on_load_path
test_jruby_ext
test_thread_context_frame_dereferences_unreachable_variables
test_context_classloader
test_context_classloader
23 changes: 23 additions & 0 deletions test/org/jruby/test/Runner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jruby.test;

public class Runner {

private static Runner runner;
public static Runner getRunner() {
if (runner == null) { runner = new Runner(); }
return runner;
}

private boolean running;

public synchronized void runJob(Runnable r) {
running = true;
r.run();
running = false;
}

public boolean isRunning() {
return running;
}

}
18 changes: 18 additions & 0 deletions test/test_java_wrapper_deadlock.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'test/unit'
require 'java'

class TestJavaWrapperDeadlock < Test::Unit::TestCase
import org.jruby.test.Runner
import java.lang.Runnable

def test_deadlock_due_to_java_object_wrapping_locking_on_java_instances
Runner.getRunner.runJob Runnable.impl {
Thread.new do
puts "geting runner instance"
runner = Runner.getRunner
puts "got runner instance"
assert runner.isRunning, "runner should be running"
end.join
}
end
end

0 comments on commit 9e0dd63

Please sign in to comment.