Skip to content

Commit

Permalink
Reorder checks to match CRuby behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Feb 14, 2025
1 parent b6971dc commit 7109a58
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/ext/fiber/ThreadFiber.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,10 @@ public IRubyObject transfer(ThreadContext context, IRubyObject[] values) {

return processResultData(context, result);
}

public IRubyObject raise(ThreadContext context, IRubyObject exception) {
Ruby runtime = context.runtime;

final FiberData data = this.data;
if (data.prev != null) throw runtime.newFiberError("double resume");

if (!alive()) throw runtime.newFiberError("dead fiber called");

FiberData currentFiberData = context.getFiber().data;
Expand All @@ -395,6 +393,9 @@ public IRubyObject raise(ThreadContext context, IRubyObject exception) {
RubyKernel.raise(context, this, exception);
}

final FiberData data = this.data;
if (data.prev != null) throw runtime.newFiberError("double resume");

if (data.parent != context.getFiberCurrentThread()) fiberCalledAcrossThreads(runtime);

FiberRequest val = new FiberRequest(((RubyException) exception).toThrowable(), RequestType.RAISE);
Expand Down

0 comments on commit 7109a58

Please sign in to comment.