call TursoDB::load from constructor

This commit is contained in:
Mikaël Francoeur
2025-07-17 10:20:21 -04:00
parent 8fe4f2163c
commit b18fd83e6f
3 changed files with 2 additions and 5 deletions

View File

@@ -98,7 +98,7 @@ public final class TursoDB implements AutoCloseable {
* @throws InternalError if the native library cannot be loaded from either the system path or the
* JAR file.
*/
public static void load() {
private static void load() {
new SingletonHolder();
}
@@ -188,6 +188,7 @@ public final class TursoDB implements AutoCloseable {
private TursoDB(String url, String filePath) throws SQLException {
this.url = url;
this.filePath = filePath;
load();
open(0);
}

View File

@@ -33,8 +33,6 @@ public final class TursoDBFactory {
throw new IllegalArgumentException("filePath should not be empty");
}
TursoDB.load();
try {
return databaseHolder.computeIfAbsent(
url, (Sneaky<String, TursoDB, SQLException>) u -> TursoDB.create(u, filePath));

View File

@@ -12,7 +12,6 @@ public class TursoDBTest {
@Test
void db_should_open_and_close_normally() throws Exception {
TursoDB.load();
String dbPath = TestUtils.createTempFile();
TursoDB db = TursoDB.create("jdbc:turso" + dbPath, dbPath);
@@ -23,7 +22,6 @@ public class TursoDBTest {
@Test
void throwJavaException_should_throw_appropriate_java_exception() throws Exception {
TursoDB.load();
String dbPath = TestUtils.createTempFile();
TursoDB db = TursoDB.create("jdbc:turso:" + dbPath, dbPath);