arturobernalg opened a new pull request, #3604: URL: https://github.com/apache/maven-surefire/pull/3604
Fixes #2098. `InPluginVMSurefireStarter.runSuitesInProcess()` builds a merged `ClassLoader` over the test classpath JARs (`createMergedClassLoader()`, which returns an `IsolatedClassLoader extends URLClassLoader`) but never closed it. Every JAR it opened stayed open for the rest of the JVM's life. This matters for embedding scenarios that reuse the same JVM across multiple in-process (non-forking) Surefire runs, e.g. via `Embedded3xLauncher`: the open JARs can't be rewritten or deleted afterward, and `java.util.ZipFile` reads of them can return stale content. Wrapped the existing provider-invocation logic in try/finally and close the classloader there if it's `Closeable` (it always is in practice, but the check keeps this safe against the declared `ClassLoader` return type). Added `InPluginVMSurefireStarterTest` with two cases: the classloader is closed after a normal run, and it's still closed when the provider setup itself fails. --- To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) check one of the following: - [x] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) - [x] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). https://claude.ai/code/session_01BrsHTdDq7PD1DoqeA9vs66 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
