Skip to content

OAK-12077 : added joinUninterruptibly() in oak-commons#2711

Merged
rishabhdaim merged 4 commits intotrunkfrom
OAK-12077
Jan 30, 2026
Merged

OAK-12077 : added joinUninterruptibly() in oak-commons#2711
rishabhdaim merged 4 commits intotrunkfrom
OAK-12077

Conversation

@rishabhdaim
Copy link
Contributor

No description provided.

@rishabhdaim rishabhdaim self-assigned this Jan 29, 2026
UninterruptibleUtils.joinUninterruptibly(worker);
long elapsedMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);

// Worker may still be alive (likely), but we at least checked the timeout behavior
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. The whole point of join() is to wait until the thread terminates. How would it still be alive after join() returns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in ebcc1b0

@Test
public void testJoinShouldWaitUntilThreadFinishes() {
final Thread worker = new Thread(() -> {
// Run longer than the join timeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in ebcc1b0

@rishabhdaim rishabhdaim requested a review from mbaedke January 29, 2026 12:39
boolean interrupted = false;

try {
for(;;) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe while(true)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are same, even at the machine code level.


// Interrupt the joining thread multiple times while it is waiting
for (int i = 0; i < 3; i++) {
Thread.sleep(50L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, too late to interrupt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed here : 31eec99

@sonarqubecloud
Copy link

@rishabhdaim rishabhdaim merged commit 7febbe5 into trunk Jan 30, 2026
3 checks passed
@rishabhdaim rishabhdaim deleted the OAK-12077 branch January 30, 2026 10:19
reschke pushed a commit that referenced this pull request Feb 4, 2026
* OAK-12077 : added joinUninterruptibly() in oak-commons

* OAK-12077 : added review comments

* OAK-12077 : updated sleep durations to sleep within joining period

* OAK-12077 : fixed assertion errors if occured in joiningThread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants