Skip to content

Prevent caching URLConnection files in ResourceFileSystem#1428

Merged
swankjesse merged 3 commits intosquare:masterfrom
pablobaxter:master
Feb 18, 2024
Merged

Prevent caching URLConnection files in ResourceFileSystem#1428
swankjesse merged 3 commits intosquare:masterfrom
pablobaxter:master

Conversation

@pablobaxter
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

@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.

}
}

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

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
Copy Markdown
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
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.

3 participants