Skip to content

TypeTable: tolerate cross-JVM races when publishing per-artifact JARs#7786

Merged
timtebeek merged 1 commit into
mainfrom
tim/delhi-v1
May 27, 2026
Merged

TypeTable: tolerate cross-JVM races when publishing per-artifact JARs#7786
timtebeek merged 1 commit into
mainfrom
tim/delhi-v1

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented May 26, 2026

Summary

  • Since Introduce JavaTypeFactory and extend JavaSourceSet with classpath fast paths #7528 switched TypeTable from writing per-class files to publishing a single per-artifact JAR via Files.move(tmpJar, jarPath, ATOMIC_MOVE, REPLACE_EXISTING), parallel Gradle test forks sharing ~/.rewrite/classpath/.tt/... could crash on Windows with AccessDeniedException when one JVM tried to replace a jar that another JVM had open. This drops REPLACE_EXISTING (the jar contents are deterministic, so the existing file is fine) and catches FileAlreadyExistsException / AccessDeniedException, accepting the on-disk jar produced by the other process and cleaning up our temp file. A regression test simulates a fresh JVM by reflectively clearing the in-process jarByArtifact map between two reads.

Test plan

  • ./gradlew :rewrite-java:test --tests TypeTableTest

Since #7528 switched TypeTable to write per-artifact JARs via
`Files.move(tmpJar, jarPath, ATOMIC_MOVE, REPLACE_EXISTING)`, parallel
Gradle test forks sharing `~/.rewrite/classpath/.tt/...` could fail on
Windows with AccessDeniedException when one JVM tried to replace a jar
that another JVM had open. Drop REPLACE_EXISTING (the jar contents are
deterministic, so the existing file is fine) and catch
FileAlreadyExistsException / AccessDeniedException, falling back to the
existing jar on disk. Adds a regression test that simulates a fresh JVM
by clearing the in-process map between two reads.
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite May 27, 2026
@timtebeek timtebeek merged commit 7c1649a into main May 27, 2026
1 check passed
@timtebeek timtebeek deleted the tim/delhi-v1 branch May 27, 2026 07:57
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite May 27, 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.

2 participants