Skip to content

Commit

Permalink
backtrace_locations are spec'd to return the same array instance o_O
Browse files Browse the repository at this point in the history
enebo committed Mar 30, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent ae31c82 commit 259b89e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ public class RubyException extends RubyObject {
IRubyObject cause;
private IRubyObject backtrace;
private RaiseException throwable;
private IRubyObject backtraceLocations;

protected RubyException(Ruby runtime, RubyClass rubyClass) {
super(runtime, rubyClass);
@@ -208,12 +209,16 @@ private void setBacktrace(IRubyObject obj) {

@JRubyMethod(omit = true)
public IRubyObject backtrace_locations(ThreadContext context) {
if (backtraceData == null) return context.nil; // Exception generated explicitly without a backtrace.

Ruby runtime = context.runtime;
RubyStackTraceElement[] elements = backtraceData.getBacktrace(runtime);
if (backtraceLocations != null) return backtraceLocations;

if (backtraceData == null) {
backtraceLocations = context.nil;
} else {
Ruby runtime = context.runtime;
backtraceLocations = RubyThread.Location.newLocationArray(runtime, backtraceData.getBacktrace(runtime));
}

return RubyThread.Location.newLocationArray(runtime, elements);
return backtraceLocations;
}

@JRubyMethod(optional = 1)

0 comments on commit 259b89e

Please sign in to comment.