Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't cache URL when loading junit-platform.properties contents #2194

Closed
1 task done
sormuras opened this issue Feb 23, 2020 · 3 comments
Closed
1 task done

Don't cache URL when loading junit-platform.properties contents #2194

sormuras opened this issue Feb 23, 2020 · 3 comments

Comments

@sormuras
Copy link
Member

sormuras commented Feb 23, 2020

Today, the code in the launcher uses the convenient input stream accessor openStream() provided by the URL class:

try (InputStream inputStream = configFileUrl.openStream()) {
props.load(inputStream);
}

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);
}
@sormuras
Copy link
Member Author

Related JBS issue JDK-8224794

@sormuras sormuras modified the milestones: 5.7 M1, 5.6.1 Mar 12, 2020
@sormuras
Copy link
Member Author

Reopened for cherry-picking into 5.6.1

@sormuras sormuras reopened this Mar 12, 2020
@sormuras
Copy link
Member Author

🍒 picked.

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

No branches or pull requests

1 participant