Skip to content

Fix GrEclipse leaving a file%3A directory in the working directory - #3162

Merged
nedtwigg merged 2 commits into
diffplug:mainfrom
toyeshhm:fix-2019-greclipse-temp-dirs
Nov 7, 2026
Merged

nedtwigg merged 2 commits into
diffplug:mainfrom
toyeshhm:fix-2019-greclipse-temp-dirs

Conversation

@toyeshhm

@toyeshhm toyeshhm commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #2019 (and its duplicate #2726).

Problem

Every JVM that starts the GrEclipse formatter leaves an empty file%3A%2Ftmp%2Fspotless-groovy-instance<N>%2F/JarUrlResolver/ directory in its working directory. That's the project root under Maven, and lib-extra/ when Spotless's own tests run. You get one per GrEclipse version per run, so they pile up.

Root cause

GrEclipseFormatterStepImpl passes a temp dir as osgi.instance.area. Solstice's BundleContextShim normalizes that value to a URL (file:/tmp/spotless-groovy-instance<N>/). ShimIdeBootstrapServices.apply then builds the JarUrlResolver dir from it like this:

new File(URLEncoder.encode(instanceArea, StandardCharsets.UTF_8))

URL-encoding turns the whole URL into a single relative file name. JarUrlResolver's constructor then mkdirs() that name in the working directory. This happens for any explicit instance area, whatever form the path takes, and Solstice 1.8.2 (the latest) still has the same code.

Fix

Pass the temp dir as osgi.instance.area.default instead of osgi.instance.area.

  • Equinox uses the default when osgi.instance.area isn't set, so the instance location (and the .metadata written there) stays in the temp dir.
  • Solstice only reads osgi.instance.area, so it no longer creates the stray directory.

The only side effect: Solstice no longer registers its jar: URLConverter. The directories it created were always empty, so formatting never used it. Dropping the instance area altogether would not work, because Equinox would then fall back to <working dir>/workspace.

Tests

  • Added GrEclipseFormatterStepTest.doesNotCreateDirectoriesInWorkingDirectory. It formats with the default version, then asserts the working directory has no file%3A* entry.
    • On main it fails, listing the file%3A%2Fvar%2Ffolders%2F...spotless-groovy-instance...%2F directory.
    • With the fix it passes.
    • If you've run the GrEclipse tests locally before, delete the leftover lib-extra/file%3A* directories first, or this test will flag them.
  • ./gradlew :lib-extra:test, :plugin-maven:test --tests com.diffplug.spotless.maven.groovy.GrEclipseTest, :lib-extra:spotlessCheck, :lib-extra:spotbugsMain and :spotlessCheck all pass.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@nedtwigg
nedtwigg merged commit 7cc923d into diffplug:main Nov 7, 2026
18 checks passed
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.

Groovy formatting with Spotless leaves a temporary directory

3 participants