Skip to content

Commit dee4f1d

Browse files
authored
Merge pull request #780 from prashantvithani/fix-timer-set-execution-jdk-11
Remove java_alias of 'submit' method of Runnable
2 parents d89681e + 5748952 commit dee4f1d

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ matrix:
99
include:
1010
- name: MRI 2.5.1 Latest
1111
rvm: 2.5.1
12-
- name: JRuby 9.2.0.0 Latest
13-
rvm: jruby-9.2.0.0
12+
- name: JRuby 9.2.4.1 Latest on Java 11
13+
rvm: jruby-9.2.4.1
14+
jdk: oraclejdk11
15+
- name: JRuby 9.2.4.1 Latest on Java 8
16+
rvm: jruby-9.2.4.1
1417
jdk: oraclejdk8
1518
- name: TruffleRuby Latest
1619
rvm: system

Rakefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,29 @@ JRUBY_JAR_PATH = '/usr/local/opt/rbenv/versions/jruby-9.1.17.0/lib/jruby.jar'
2323
class ConcurrentRubyJavaExtensionTask < Rake::JavaExtensionTask
2424
def java_classpath_arg(*args)
2525
jruby_cpath = nil
26+
2627
if RUBY_PLATFORM =~ /java/
2728
begin
2829
cpath = Java::java.lang.System.getProperty('java.class.path').split(File::PATH_SEPARATOR)
2930
cpath += Java::java.lang.System.getProperty('sun.boot.class.path').split(File::PATH_SEPARATOR)
3031
jruby_cpath = cpath.compact.join(File::PATH_SEPARATOR)
3132
rescue => e
3233
end
34+
35+
unless jruby_cpath
36+
libdir = RbConfig::CONFIG['libdir']
37+
if libdir.start_with? "classpath:"
38+
raise 'Cannot build with jruby-complete'
39+
end
40+
jruby_cpath = File.join(libdir, "jruby.jar")
41+
end
3342
end
43+
3444
unless jruby_cpath
3545
jruby_cpath = JRUBY_JAR_PATH
3646
raise "#{jruby_cpath} does not exist" unless File.exist? jruby_cpath
3747
end
48+
3849
jruby_cpath += File::PATH_SEPARATOR + args.join(File::PATH_SEPARATOR) unless args.empty?
3950
jruby_cpath ? "-cp \"#{jruby_cpath}\"" : ""
4051
end

lib/concurrent/executor/java_executor_service.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ class JavaExecutorService < AbstractExecutorService
2020

2121
def initialize(*args, &block)
2222
super
23-
ns_make_executor_runnable
2423
end
2524

2625
def post(*args, &task)
2726
raise ArgumentError.new('no block given') unless block_given?
2827
return handle_fallback(*args, &task) unless running?
29-
@executor.submit_runnable Job.new(args, task)
28+
@executor.submit Job.new(args, task)
3029
true
3130
rescue Java::JavaUtilConcurrent::RejectedExecutionException
3231
raise RejectedExecutionError
@@ -75,14 +74,6 @@ def ns_shutdown?
7574
@executor.isShutdown || @executor.isTerminated
7675
end
7776

78-
def ns_make_executor_runnable
79-
if !defined?(@executor.submit_runnable)
80-
@executor.class.class_eval do
81-
java_alias :submit_runnable, :submit, [java.lang.Runnable.java_class]
82-
end
83-
end
84-
end
85-
8677
class Job
8778
include Runnable
8879
def initialize(args, block)

spec/concurrent/synchronization_spec.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,20 @@ def ns_initialize
181181

182182
specify 'final field always visible' do
183183
store = BClass.new 'asd'
184-
t1 = in_thread { 1000000000.times { |i| store = BClass.new i.to_s } }
185-
t2 = in_thread { 10.times { expect(store.final).not_to be_nil; Thread.pass } }
186-
t2.join
187-
t1.kill
184+
done = CountDownLatch.new
185+
in_thread do
186+
1000000000.times do |i|
187+
store = BClass.new i.to_s
188+
break if done.count == 0
189+
end
190+
end
191+
in_thread do
192+
10.times do
193+
expect(store.final).not_to be_nil
194+
Thread.pass
195+
end
196+
done.count_down
197+
end
188198
end
189199

190200
let(:store) { BClass.new }

0 commit comments

Comments
 (0)