Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from Jan 2, 2016
Merged

Conversation

kares
Copy link
Member

@kares 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 forceing a nil (no) backtrace with Java APIs forcing a nil (no) backtrace with Java APIs Nov 23, 2015
kares added a commit to jruby/jruby-openssl that referenced this issue Dec 17, 2015
…array)

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

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 issue Jan 2, 2016
forcing a nil (no) backtrace with Java APIs
@kares kares merged commit dbc4b02 into master Jan 2, 2016
1 check passed
@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant