Skip to content

Commit

Permalink
add a test (from jruby#1621) for guarding against dead-locks in proxy…
Browse files Browse the repository at this point in the history
…-class initialization
  • Loading branch information
kares committed Mar 2, 2015
1 parent f857e70 commit 61acccd
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/Bug1621A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621A {
static final Bug1621A INSTANCE = new Bug1621A();
public static final Bug1621B NEXT = Bug1621B.INSTANCE;
}
4 changes: 4 additions & 0 deletions test/Bug1621B.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621B {
static final Bug1621B INSTANCE = new Bug1621B();
public static final Bug1621C NEXT = Bug1621C.INSTANCE;
}
4 changes: 4 additions & 0 deletions test/Bug1621C.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621C {
static final Bug1621C INSTANCE = new Bug1621C();
public static final Bug1621D NEXT = Bug1621D.INSTANCE;
}
4 changes: 4 additions & 0 deletions test/Bug1621D.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621D {
static final Bug1621D INSTANCE = new Bug1621D();
public static final Bug1621E NEXT = Bug1621E.INSTANCE;
}
4 changes: 4 additions & 0 deletions test/Bug1621E.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621E {
static final Bug1621E INSTANCE = new Bug1621E();
public static final Bug1621F NEXT = Bug1621F.INSTANCE;
}
4 changes: 4 additions & 0 deletions test/Bug1621F.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621F {
static final Bug1621F INSTANCE = new Bug1621F();
public static final Bug1621G NEXT = Bug1621G.INSTANCE;
}
4 changes: 4 additions & 0 deletions test/Bug1621G.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621G {
static final Bug1621G INSTANCE = new Bug1621G();
public static final Bug1621H NEXT = Bug1621H.INSTANCE;
}
4 changes: 4 additions & 0 deletions test/Bug1621H.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Bug1621H {
static final Bug1621H INSTANCE = new Bug1621H();
public static final Bug1621A NEXT = Bug1621A.INSTANCE;
}
19 changes: 18 additions & 1 deletion test/test_higher_javasupport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def test_no_warnings_on_concurrent_class_const_initialization
end

# reproducing https://github.com/jruby/jruby/issues/2014
def test_concurrent_proxy_class_initialization
def test_concurrent_proxy_class_initialization_invalid_method_dispatch
abort_on_exception = Thread.abort_on_exception
begin
Thread.abort_on_exception = true
Expand All @@ -898,7 +898,24 @@ def test_concurrent_proxy_class_initialization
ensure
Thread.abort_on_exception = abort_on_exception
end
end

# reproducing https://github.com/jruby/jruby/issues/1621
def test_concurrent_proxy_class_initialization_dead_lock
timeout = 0.5; threads_to_kill = []
begin
threads = %w{ A B C D E F G H }.map do |sym|
Thread.new { Java::Default.const_get "Bug1621#{sym}" }
end
threads.each do |thread|
threads_to_kill << thread if thread.join(timeout).nil?
end
if threads_to_kill.any?
fail "threads: #{threads_to_kill.inspect} dead-locked!"
end
ensure
threads_to_kill.each { |thread| thread.exit rescue nil }
end
end

end

0 comments on commit 61acccd

Please sign in to comment.