Skip to content

8306324: StopThread results in thread being marked as interrupted, leading to unexpected InterruptedException #26365

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/hotspot/share/runtime/javaThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,10 @@ void JavaThread::handle_async_exception(oop java_throwable) {
// We cannot call Exceptions::_throw(...) here because we cannot block
set_pending_exception(java_throwable, __FILE__, __LINE__);

oop vt_oop = vthread();
if (vt_oop == nullptr || !vt_oop->is_a(vmClasses::BaseVirtualThread_klass())) {
java_lang_Thread::set_interrupted(threadObj(), false);
}
clear_scopedValueBindings();

LogTarget(Info, exceptions) lt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ public void run() {
log("TestTask.run: caught expected AssertionError from method A()");
seenExceptionFromA = true;
}
Thread.interrupted();
if (!seenExceptionFromA && !preemptableVirtualThread()) {
StopThreadTest.setFailed("TestTask.run: expected AssertionError from method A()");
}
Expand All @@ -224,7 +223,6 @@ public void run() {
log("TestTask.run: caught expected AssertionError from method B()");
seenExceptionFromB = true;
}
Thread.interrupted();
if (!seenExceptionFromB) {
StopThreadTest.setFailed("TestTask.run: expected AssertionError from method B()");
}
Expand All @@ -237,7 +235,6 @@ public void run() {
log("TestTask.run: caught expected AssertionError from method C()");
seenExceptionFromC = true;
}
Thread.interrupted();
if (!seenExceptionFromC) {
StopThreadTest.setFailed("TestTask.run: expected AssertionError from method C()");
}
Expand Down