Skip to content

Reset Thread interrupted state after catching InterruptedException#6438

Open
dlmarion wants to merge 1 commit into
apache:2.1from
dlmarion:fix-catch-ioe
Open

Reset Thread interrupted state after catching InterruptedException#6438
dlmarion wants to merge 1 commit into
apache:2.1from
dlmarion:fix-catch-ioe

Conversation

@dlmarion

@dlmarion dlmarion commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This commit resets the thread interrupted state after catching InterruptedException. These changes were made by running the Maven command below, reviewing the changes, and making some manual modifications.

mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
    --define rewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-static-analysis:RELEASE \
    --define rewrite.activeRecipes=org.openrewrite.staticanalysis.InterruptedExceptionHandling \
    --define rewrite.exportDatatables=true

The related documentation for this Maven plugin can be found at https://docs.openrewrite.org/recipes/staticanalysis/interruptedexceptionhandling

This commit resets the thread interrupted state after catching
InterruptedException. These changes were made by running the
Maven command below, reviewing the changes, and making some
manual modifications.

mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
    --define rewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-static-analysis:RELEASE \
    --define rewrite.activeRecipes=org.openrewrite.staticanalysis.InterruptedExceptionHandling \
    --define rewrite.exportDatatables=true

The related documentation for this Maven plugin can be found
at https://docs.openrewrite.org/recipes/staticanalysis/interruptedexceptionhandling
@dlmarion dlmarion added this to the 2.1.5 milestone Jun 22, 2026
@dlmarion dlmarion self-assigned this Jun 22, 2026
@dlmarion dlmarion changed the title Reset Thread interrupted state after catching IOE Reset Thread interrupted state after catching InterruptedException Jun 24, 2026
@dlmarion

Copy link
Copy Markdown
Contributor Author

ITs passed. ZombieScanIT timed out initially, but ran at a later time with no issues.

@dlmarion dlmarion marked this pull request as ready for review June 24, 2026 20:34
@ctubbsii

Copy link
Copy Markdown
Member

This plugin kinda works like our formatter profile does, with the formatter, impsort, and rat plugins. I wonder if it'd be worth adding it there, or if we should just create a GitHub Action to check if it produces a diff.

@ctubbsii ctubbsii 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.

This is a good change, but I wonder how many of these cases could be better handled if we just didn't rethrow it everywhere. InterruptedException seems to leak a lot from ZK and other places, and we have a tendency to just throw it up rather than handle it immediately.

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.

2 participants