Skip to content

chore: #2058 Re-interrupt thread when catching InterruptedException - #2062

Merged
lbroudoux merged 1 commit into
microcks:masterfrom
Heyy-Himanshuu:chore/2058-reinterrupt-interrupted-exception
Apr 30, 2026
Merged

lbroudoux merged 1 commit into
microcks:masterfrom
Heyy-Himanshuu:chore/2058-reinterrupt-interrupted-exception

Conversation

@Heyy-Himanshuu

Copy link
Copy Markdown
Contributor

Description

  • minions/async — AsyncAPITestManager.AsyncAPITestThread#run (L129): re-interrupt after logging that the test thread was interrupted.
  • minions/async — NATSMessageConsumptionTask#close (L137): re-interrupt after logging the close-time exception so callers can still observe cancellation.
  • webapp — MockControllerCommons#waitForDelay (L350): narrow the overly broad catch (Exception) to catch (InterruptedException) — Object#wait() only declares InterruptedException, and the surrounding synchronized (semaphore) block guarantees we hold the monitor, so the catch was wider than necessary — then re-interrupt.
  • No behavioural change on the normal exception-free path. Interrupted threads will now correctly propagate the interrupt signal up the stack.
  • mvn spotless:check -pl minions/async,webapp passes locally.

Related issue(s)

See also #2058

…eption

Sonar flagged three catch blocks that swallow InterruptedException
without preserving the thread's interrupted status, so callers waiting
on cancellation never see the signal. Restore the canonical pattern
of calling Thread.currentThread().interrupt() in the catch body.

- AsyncAPITestManager.AsyncAPITestThread#run (L129): re-interrupt
  after logging that the test thread was interrupted.
- NATSMessageConsumptionTask#close (L137): re-interrupt after logging
  the close-time exception so callers can still observe cancellation.
- MockControllerCommons#waitForDelay (L350): narrow the overly broad
  catch (Exception) to catch (InterruptedException) - Object#wait only
  declares InterruptedException, and the surrounding synchronized
  block guarantees we hold the monitor - then re-interrupt.

No behavioural change for the normal exception-free path; threads
that get interrupted while waiting will now correctly propagate the
interrupt signal up the stack.

Signed-off-by: Git-HimanshuRathi <[email protected]>

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thank you!

@lbroudoux lbroudoux added kind/task java Pull requests that update Java code labels Apr 30, 2026
@lbroudoux lbroudoux added this to the 1.15.0 milestone Apr 30, 2026
@lbroudoux
lbroudoux merged commit 052e02c into microcks:master Apr 30, 2026
14 of 15 checks passed
@Heyy-Himanshuu
Heyy-Himanshuu deleted the chore/2058-reinterrupt-interrupted-exception branch May 1, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code kind/task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants