-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid using shared resource streams between class loaders when extrac…
…ting the native library. (#578) This changes makes it so that we replace Class#getResoirceAsStream() with a custom method that finds the resources and creates a stream but disables caching the stream. This is necessary in environments with where the native library has to be extracted and used with multiple class loaders that get closed. Specifically, I was observing the following [JDK-8205976](https://bugs.openjdk.java.net/browse/JDK-8205976) in a [Gradle](https://gradle.org/) project with concurrent tasks that use sqlite-jdbc. The exact exception I was observing was: ``` java.io.IOException: Stream closed at java.base/java.util.zip.InflaterInputStream.ensureOpen(InflaterInputStream.java:68) at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:143) at java.base/java.io.FilterInputStream.read(FilterInputStream.java:133) at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:252) at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:271) at org.sqlite.SQLiteJDBCLoader.contentsEquals(SQLiteJDBCLoader.java:179) at org.sqlite.SQLiteJDBCLoader.extractAndLoadLibraryFile(SQLiteJDBCLoader.java:243) at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:344) at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:67) ``` Which lead me to JDK-8205976 after lots of logging. The test is a big complicated but sets ups the exact case for when this occurs. Multiple concurrent threads with isolated class loaders initializing the library for which the resource on all point to the same jar.
- Loading branch information
1 parent
2eeb817
commit bf5e840
Showing
2 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters