Skip to content

Fix ClassCastException in InterruptedExceptionHandling on Kotlin sources - #1045

Merged
greg-at-moderne merged 1 commit into
mainfrom
greg-interrupted-exception-kotlin-npe
Sep 2, 2026
Merged

Fix ClassCastException in InterruptedExceptionHandling on Kotlin sources#1045
greg-at-moderne merged 1 commit into
mainfrom
greg-interrupted-exception-kotlin-npe

Conversation

@greg-at-moderne

@greg-at-moderne greg-at-moderne commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What's changed?

Removing contextSensitive from template usages in InterruptedExceptionHandling.

What's your motivation?

  • They are not needed
  • With them present, the recipe might crash for Kotlin sources:
java.lang.NullPointerException: Cannot invoke "org.openrewrite.java.tree.J$Block.getStatements()" because the return value of "org.openrewrite.java.tree.J$ClassDeclaration.getBody()" is null
  org.openrewrite.kotlin.internal.KotlinPrinter$KotlinJavaPrinter.visitClassDeclaration0(KotlinPrinter.java:759)
  org.openrewrite.kotlin.internal.KotlinPrinter$KotlinJavaPrinter.visitClassDeclaration(KotlinPrinter.java:731)
  org.openrewrite.kotlin.internal.KotlinPrinter$KotlinJavaPrinter.visitClassDeclaration(KotlinPrinter.java:557)
  org.openrewrite.java.tree.J$ClassDeclaration.acceptJava(J.java:1382)
  org.openrewrite.java.tree.J.accept(J.java:55)
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:242)
  org.openrewrite.kotlin.internal.KotlinPrinter$KotlinJavaPrinter.visit(KotlinPrinter.java:570)
  org.openrewrite.kotlin.internal.KotlinPrinter.visit(KotlinPrinter.java:56)
  org.openrewrite.kotlin.internal.KotlinPrinter.visit(KotlinPrinter.java:40)
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:154)
  org.openrewrite.Tree.print(Tree.java:86)
  org.openrewrite.Tree.print(Tree.java:82)
  org.openrewrite.Tree.printTrimmed(Tree.java:119)

@greg-at-moderne greg-at-moderne self-assigned this Sep 1, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Sep 1, 2026
@greg-at-moderne
greg-at-moderne marked this pull request as ready for review September 2, 2026 07:57
@greg-at-moderne
greg-at-moderne merged commit 5e9eb85 into main Sep 2, 2026
1 check passed
@greg-at-moderne
greg-at-moderne deleted the greg-interrupted-exception-kotlin-npe branch September 2, 2026 07:57
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant