forcing a nil (no) backtrace with Java APIs #3488

Merged
merged 5 commits into from Jan 2, 2016

Conversation

Projects
None yet
1 participant
@kares
Member

kares commented Nov 23, 2015

RaiseException(Ruby runtime, RubyClass type, String msg, IRubyObject backtrace, boolean native) constructor despite accepting an IRubyObject backtrace parameter (and not just RubyArray), passing a nil does not end up with the RubyException#backtrace being nil but rather an empty array which is not fortunate as in user-land its easy to dismiss and confusing.

like to use the constructor for optional "lightweight" exception raising such as jruby/jruby-openssl#55

p.s. I'd like to consider backporting these changes to jruby-1_7 if there's no objections to that.

@kares kares changed the title from forceing a nil (no) backtrace with Java APIs to forcing a nil (no) backtrace with Java APIs Nov 23, 2015

@kares kares referenced this pull request in jruby/jruby-openssl Nov 25, 2015

Closed

WaitReadable/Writable exceptions generate backtraces #55

kares added a commit to jruby/jruby-openssl that referenced this pull request Dec 17, 2015

disable backtrace generation for wait non-block errors (use an empty …
…array)

... little more confusing than a `nil` but for now has todo (until jruby/jruby#3488)
@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Jan 2, 2016

Member

the changes also slightly improved performance (when backtrace is not accessed) e.g.

require 'hitimes'

def measure(count = 1_000)
  Hitimes::Interval.measure do
    count.times do
      begin
        raise RuntimeError.new
      rescue RuntimeError => e
        puts e.message if false
      end
    end
  end
end

print "warmup: "
puts measure(200_000).inspect
print "......: "
puts measure(500_000).inspect

BEFORE:

warmup: 12.830130032
......: 29.00416128

warmup: 12.668082653
......: 27.926976294

warmup: 12.572626931
......: 28.33092909

AFTER:

warmup: 11.538297404
......: 25.360850043

warmup: 11.461425197
......: 25.174530815

warmup: 12.311494166
......: 26.668306498
Member

kares commented Jan 2, 2016

the changes also slightly improved performance (when backtrace is not accessed) e.g.

require 'hitimes'

def measure(count = 1_000)
  Hitimes::Interval.measure do
    count.times do
      begin
        raise RuntimeError.new
      rescue RuntimeError => e
        puts e.message if false
      end
    end
  end
end

print "warmup: "
puts measure(200_000).inspect
print "......: "
puts measure(500_000).inspect

BEFORE:

warmup: 12.830130032
......: 29.00416128

warmup: 12.668082653
......: 27.926976294

warmup: 12.572626931
......: 28.33092909

AFTER:

warmup: 11.538297404
......: 25.360850043

warmup: 11.461425197
......: 25.174530815

warmup: 12.311494166
......: 26.668306498

kares added a commit that referenced this pull request Jan 2, 2016

Merge pull request #3488 from jruby/force-backtrace-nil
forcing a nil (no) backtrace with Java APIs

@kares kares merged commit dbc4b02 into master Jan 2, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kares kares added this to the JRuby 9.0.5.0 milestone Jan 2, 2016

@kares kares deleted the force-backtrace-nil branch Jan 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment