Skip to content

fix: Prevent stale JAR cache in Reflector under Maven daemon (mvnd)#23863

Draft
mcollovati wants to merge 1 commit intoissue/15458-gradle_plugin_scan_jars_issuefrom
issue/15458-maven_plugin_scan_jars_issue
Draft

fix: Prevent stale JAR cache in Reflector under Maven daemon (mvnd)#23863
mcollovati wants to merge 1 commit intoissue/15458-gradle_plugin_scan_jars_issuefrom
issue/15458-maven_plugin_scan_jars_issue

Conversation

@mcollovati
Copy link
Collaborator

Mirror the Gradle daemon fix (33fa374) in the Maven plugin's Reflector and ReflectorClassLoader/CombinedClassLoader:

  • Extract ReflectionsClassFinder.disableJarCaching() as a public utility so both plugins can reuse it.
  • Wrap jar: URLs in ReflectorClassLoader.getResource() and getResources() (flow-maven-plugin) and CombinedClassLoader (flow-dev-bundle-plugin) with useCaches(false) to prevent stale JarFileFactory entries across daemon builds.
  • Make Reflector implement Closeable with a close() method that releases the URLClassLoader file handles, and register a Cleaner action for best-effort GC cleanup of abandoned instances.
  • Close the temporary Reflector in FlowModeAbstractMojo.isHillaAvailable(MavenProject) via try-with-resources.

Related to #15458

Mirror the Gradle daemon fix (33fa374) in the Maven plugin's
`Reflector` and `ReflectorClassLoader`/`CombinedClassLoader`:

- Extract `ReflectionsClassFinder.disableJarCaching()` as a public
  utility so both plugins can reuse it.
- Wrap `jar:` URLs in `ReflectorClassLoader.getResource()` and
  `getResources()` (flow-maven-plugin) and `CombinedClassLoader`
  (flow-dev-bundle-plugin) with `useCaches(false)` to prevent stale
  `JarFileFactory` entries across daemon builds.
- Make `Reflector` implement `Closeable` with a `close()` method that
  releases the `URLClassLoader` file handles, and register a
  `Cleaner` action for best-effort GC cleanup of abandoned instances.
- Close the temporary `Reflector` in
  `FlowModeAbstractMojo.isHillaAvailable(MavenProject)` via
  try-with-resources.

Releated to #15458
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants