Skip to content

Also check thread context classloader in TypeTable.fromClasspath()#6900

Merged
timtebeek merged 1 commit intomainfrom
fix/tsv-classloader-resolution
Mar 10, 2026
Merged

Also check thread context classloader in TypeTable.fromClasspath()#6900
timtebeek merged 1 commit intomainfrom
fix/tsv-classloader-resolution

Conversation

@knutwannheden
Copy link
Contributor

Summary

  • TypeTable.fromClasspath() now also searches the thread context classloader (TCCL) in addition to the caller's classloader when looking for classpath.tsv.gz resources
  • Fixes Rewrite fails to load classpath.tsv.gz resources from additional GAVs of recipes #6885: when recipe JARs are loaded via a custom URLClassLoader (e.g. in Quarkus), the caller's classloader (AppClassLoader) can't see those JARs' resources — the TCCL can
  • URLs are collected into a LinkedHashSet to deduplicate when both classloaders see the same resources
  • Removes the expired .zip extension fallback (TO-BE-REMOVED 2025-10-31)

Test plan

  • New test findsResourcesFromThreadContextClassLoader creates an isolated URLClassLoader with a classpath.tsv.gz, sets it as TCCL, and verifies fromClasspath() finds the resource
  • Existing TypeTable tests continue to pass (resources found via caller's classloader as before)

When recipe JARs are loaded via a custom URLClassLoader (e.g. Quarkus),
the caller's classloader cannot see their classpath.tsv.gz resources.
Now fromClasspath() also searches the thread context classloader,
which frameworks set to a classloader with full visibility.

Also removes the expired .zip extension fallback (TO-BE-REMOVED 2025-10-31).

Fixes #6885
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 10, 2026
@knutwannheden knutwannheden changed the title Also check thread context classloader in TypeTable.fromClasspath() Also check thread context classloader in TypeTable.fromClasspath() Mar 10, 2026
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Mar 10, 2026
@timtebeek timtebeek merged commit 0c5a2f4 into main Mar 10, 2026
1 check passed
@timtebeek timtebeek deleted the fix/tsv-classloader-resolution branch March 10, 2026 08:53
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Mar 10, 2026
knutwannheden added a commit that referenced this pull request Mar 10, 2026
PR #6900 accidentally dropped the .zip extension fallback when
refactoring fromClasspath() to also check the thread context
classloader. Downstream repos like rewrite-feature-flags still
package their TypeTable data as classpath.tsv.zip, causing
"Unable to find classpath resource dependencies" failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Rewrite fails to load classpath.tsv.gz resources from additional GAVs of recipes

2 participants