Skip to content

Commit

Permalink
Merge pull request #9933 from brianwyka/duckdbnative-close-resource
Browse files Browse the repository at this point in the history
JDBC: DuckDBNative - Close Shared Object InputStream Properly
  • Loading branch information
Mytherin committed Dec 9, 2023
2 parents 3abc5eb + 2fb4320 commit d423e96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/jdbc/src/main/java/org/duckdb/DuckDBNative.java
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.file.Files;
Expand Down Expand Up @@ -50,7 +51,9 @@ public class DuckDBNative {
System.load(
Paths.get("../../build/debug/tools/jdbc", lib_res_name).normalize().toAbsolutePath().toString());
} else {
Files.copy(lib_res.openStream(), lib_file, StandardCopyOption.REPLACE_EXISTING);
try (final InputStream lib_res_input_stream = lib_res.openStream()) {
Files.copy(lib_res_input_stream, lib_file, StandardCopyOption.REPLACE_EXISTING);
}
new File(lib_file.toString()).deleteOnExit();
System.load(lib_file.toAbsolutePath().toString());
}
Expand Down

0 comments on commit d423e96

Please sign in to comment.