From a2511e3dc88a35f940c24b119800d2f9222edead Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Wed, 6 Nov 2024 18:06:15 -0600 Subject: [PATCH] Set group only if we don't do add logic Setting the new group before the add logic causes breaks the removal from the thread's old group. Instead, only directly set the thread's group if we won't run the add logic. --- core/src/main/java/org/jruby/RubyThreadGroup.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/jruby/RubyThreadGroup.java b/core/src/main/java/org/jruby/RubyThreadGroup.java index 652c4939b83..9518e013d41 100644 --- a/core/src/main/java/org/jruby/RubyThreadGroup.java +++ b/core/src/main/java/org/jruby/RubyThreadGroup.java @@ -95,12 +95,11 @@ public IRubyObject add(ThreadContext context, IRubyObject rubyThread, Block bloc } } - // always set group when added explicitly - thread.setThreadGroup(this); - // we only add live threads if (thread.alive_p(context).isTrue()) { addDirectly(thread); + } else { + thread.setThreadGroup(this); } return this;