-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Don't cache URL when loading junit-platform.properties contents #2194
Copy link
Copy link
Closed
Description
Today, the code in the launcher uses the convenient input stream accessor openStream() provided by the URL class:
This implicitly caches an underlying JAR file for the current VM, if the junit-platform.properties file is located in a JAR file. On Windows, that means a lock is held by the VM until its associated reference is garbage collected.
When, for example, testing the launcher framework within a test method that prepares a custom class-path or module-path with generated JAR files in a temporary directory, that temporary directory can't be deleted on Windows, due the lock of the cached JAR file reference.
Deliverables
- Use the following code to prevent caching of an underlying JAR file:
URLConnection urlConnection = configFileUrl.openConnection();
urlConnection.setUseCaches(false);
try (InputStream inputStream = urlConnection.getInputStream()) {
props.load(inputStream);
}Reactions are currently unavailable