This issue is reported in JRuby https://github.com/jruby/jruby/issues/4239 reported by @nateberkopec
To reproduce (TruffleRuby 1.0.0 RC 11):
def build_exception_with_cause
begin
1 / 0
rescue ZeroDivisionError
1 / 0
end
rescue ZeroDivisionError => exception
return exception
end
exc = build_exception_with_cause
exc.cause
exc.cause would return #<ZeroDivisionError: divided by 0> not nil in case of TruffleRuby.
Thank you for the report.
I can reproduce the bug on master.
A slightly clearer reproducer:
def build_exception_with_cause
begin
raise "first"
rescue
1 / 0
end
rescue ZeroDivisionError => exception
return exception
end
exc = build_exception_with_cause
p exc.cause
i.e., ZeroDivisionError doesn't capture the cause.
Swapping them works, i.e., exceptions from raise capture the cause.
This causes an issue in Sidekiq on this place https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/processor.rb#L176
Due to this, plenty tests fail.
@eregon @chrisseaton when this issue is quick to fix, please try to fix it to RC13. This fixes almost or all failed tests in Sidekiq. Sidekiq depends heavily on this behaviour.
I'll take a look at this.
Fixed by ee80ecd1002495f06b6da6855221919fab9611bc.
@deepj Thanks for the report, I took the occasion to fix a couple more Exception#cause-related bugs.