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

Prevent caching URLConnection files in ResourceFileSystem #1428

Merged
merged 3 commits into from
Feb 18, 2024

Conversation

pablobaxter
Copy link
Contributor

This fix is for #1364. It prevents the issue where ClassLoader.getResourceAsStream() caches an open file due to URLConnection.openStream() works. More details in #1364 (comment).

Copy link
Member

@swankjesse swankjesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rad. Good fix.

@@ -109,3 +145,18 @@ private inline fun <R> ZipOutputStream.putEntry(name: String, action: BufferedSi
closeEntry()
}
}

// This is a Linux only test for open file descriptors on the current process
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neato

private fun Path.assetFileNotOpen() {
val fds = Path("/proc/self/fd")
if (fds.isDirectory()) {
// Linux: verify that path is not open
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this only works on linux, some kind of assumeTrue to skip the test on other platforms would be useful to prevent future "WTF" moments where the tests pass on macOS because they don't assert anything then fail in CI

@swankjesse swankjesse merged commit b8dbaae into square:master Feb 18, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants