Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9db412f456c7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 51124a629bad
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 6, 2016

  1. Fix regression spec for #4202.

    headius committed Oct 6, 2016
    Copy the full SHA
    8a4a945 View commit details
  2. Copy the full SHA
    51124a6 View commit details
21 changes: 12 additions & 9 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -657,16 +657,19 @@ public static IRubyObject sleep(ThreadContext context, IRubyObject recv, IRubyOb

final long startTime = System.currentTimeMillis();
final RubyThread rubyThread = context.getThread();
// Spurious wakeup-loop
do {
long loopStartTime = System.currentTimeMillis();
try {
// We break if we know this sleep was explicitly woken up/interrupted
if ( ! rubyThread.sleep(milliseconds) ) break;
} catch (InterruptedException ex) { /* no-op */ }
milliseconds -= (System.currentTimeMillis() - loopStartTime);

try {
// Spurious wakeup-loop
do {
long loopStartTime = System.currentTimeMillis();

if (!rubyThread.sleep(milliseconds)) break;

milliseconds -= (System.currentTimeMillis() - loopStartTime);
} while (milliseconds > 0);
} catch (InterruptedException ie) {
// ignore; sleep gets interrupted
}
while (milliseconds > 0);

return context.runtime.newFixnum(Math.round((System.currentTimeMillis() - startTime) / 1000.0));
}
12 changes: 8 additions & 4 deletions spec/regression/GH-4202_gzipreader_respond_to_spec.rb
Original file line number Diff line number Diff line change
@@ -8,18 +8,22 @@

it "supports all respond_to? arities" do
gzw = Zlib::GzipWriter.open(@tempfile.path)
gzw.respond_to?(:path).should == true
gzw.respond_to?(:path, false).should == true
expect(gzw.respond_to?(:path)).to be true
expect(gzw.respond_to?(:path, false)).to be true
end
end

describe "A GzipReader instance" do
before do
@tempfile = Tempfile.new("GH-4202")
end

it "supports all respond_to? arities" do
gzw = Zlib::GzipWriter.open(@tempfile.path)
gzw << "content"
gzw.close
gzr = Zlib::GzipReader.open(@tempfile.path)
gzr.respond_to?(:path).should == true
gzr.respond_to?(:path, false).should == true
expect(gzr.respond_to?(:path)).to be true
expect(gzr.respond_to?(:path, false)).to be true
end
end
12 changes: 12 additions & 0 deletions spec/regression/GH-4206_kernel_sleep_interruptedexception_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe "Kernel#sleep" do
it "can be interrupted using java.lang.Thread.interrupt" do
t = Thread.new do
Kernel.sleep
:ok
end

JRuby.reference(t).native_thread.interrupt

expect(t.value).to eq :ok
end
end