Skip to content

Commit 2471575

Browse files
committed
3.50.0.0-SNAPSHOT
2 parents 3742723 + bbb2d02 commit 2471575

File tree

8 files changed

+137
-36
lines changed

8 files changed

+137
-36
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
runs-on: ubuntu-latest
125125
steps:
126126
- uses: actions/checkout@v4
127-
- uses: uraimo/run-on-arch-action@v2
127+
- uses: uraimo/run-on-arch-action@v3
128128
name: Test
129129
with:
130130
arch: ${{ matrix.arch }}

VERSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=3.49.2
2-
artifactVersion=3.49.2.0
3-
sqliteMCVersion=2.1.1
1+
version=3.50.0
2+
artifactVersion=3.50.0.0-SNAPSHOT
3+
sqliteMCVersion=2.1.2

pom.xml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>io.github.willena</groupId>
66
<artifactId>sqlite-jdbc</artifactId>
7-
<version>3.49.2.0</version>
7+
<version>3.50.0.0-SNAPSHOT</version>
88
<name>SQLite JDBC</name>
99
<description>SQLite JDBC library with encryption and authentication support</description>
1010
<url>https://github.com/Willena/sqlite-jdbc-crypt</url>
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<junit.version>5.11.4</junit.version>
15-
<surefire.version>3.5.2</surefire.version>
16-
<archunit.version>1.4.0</archunit.version>
14+
<junit.version>5.12.2</junit.version>
15+
<surefire.version>3.5.3</surefire.version>
16+
<archunit.version>1.4.1</archunit.version>
1717
<graalvm.version>24.1.2</graalvm.version>
1818
<java9.sourceDirectory>${project.basedir}/src/main/java9</java9.sourceDirectory>
1919
</properties>
@@ -99,7 +99,7 @@
9999
<plugin>
100100
<groupId>org.apache.maven.plugins</groupId>
101101
<artifactId>maven-compiler-plugin</artifactId>
102-
<version>3.13.0</version>
102+
<version>3.14.0</version>
103103
<configuration>
104104
<release>8</release>
105105
</configuration>
@@ -340,7 +340,7 @@
340340
<plugin>
341341
<groupId>org.graalvm.buildtools</groupId>
342342
<artifactId>native-maven-plugin</artifactId>
343-
<version>0.10.5</version>
343+
<version>0.10.6</version>
344344
<extensions>true</extensions>
345345
<executions>
346346
<execution>
@@ -357,6 +357,15 @@
357357
<buildArgs>
358358
<!-- required to allow junit-pioneer to compile with strict image heap enabled -->
359359
<arg>--initialize-at-build-time=org.junitpioneer.jupiter.issue.IssueExtensionExecutionListener</arg>
360+
<!--
361+
Issues with JUnit support should be largely resolved by https://github.com/graalvm/native-build-tools/issues/613
362+
These are only necessary for GraalVM for JDK 22+ as this has the Strict Image Heap enabled by default,
363+
and should be removed when aforementioned issue is released in a new buildtools release.
364+
-->
365+
<arg>--initialize-at-build-time=org.junit.jupiter.engine.descriptor.ExclusiveResourceCollector$DefaultExclusiveResourceCollector</arg>
366+
<arg>--initialize-at-build-time=org.junit.jupiter.api.parallel.ResourceLock</arg>
367+
<arg>--initialize-at-build-time=org.junit.jupiter.api.parallel.ResourceLockTarget</arg>
368+
<arg>--initialize-at-build-time=org.junit.jupiter.api.parallel.ResourceAccessMode</arg>
360369
</buildArgs>
361370
</configuration>
362371
</plugin>
@@ -433,7 +442,6 @@
433442
<dependency>
434443
<groupId>org.junit.jupiter</groupId>
435444
<artifactId>junit-jupiter</artifactId>
436-
<version>${junit.version}</version>
437445
<scope>test</scope>
438446
</dependency>
439447
<dependency>
@@ -461,7 +469,7 @@
461469
<dependency>
462470
<groupId>org.mockito</groupId>
463471
<artifactId>mockito-core</artifactId>
464-
<version>5.15.2</version>
472+
<version>5.18.0</version>
465473
<scope>test</scope>
466474
</dependency>
467475
<dependency>
@@ -478,4 +486,15 @@
478486
<scope>test</scope>
479487
</dependency>
480488
</dependencies>
489+
<dependencyManagement>
490+
<dependencies>
491+
<dependency>
492+
<groupId>org.junit</groupId>
493+
<artifactId>junit-bom</artifactId>
494+
<version>${junit.version}</version>
495+
<type>pom</type>
496+
<scope>import</scope>
497+
</dependency>
498+
</dependencies>
499+
</dependencyManagement>
481500
</project>

src/main/java/org/sqlite/SQLiteConnection.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -254,26 +254,7 @@ private static DB open(String url, String origFileName, Properties props) throws
254254
throw new SQLException(String.format("failed to load %s: %s", resourceName, e));
255255
}
256256
} else {
257-
File file = new File(fileName).getAbsoluteFile();
258-
File parent = file.getParentFile();
259-
if (parent != null && !parent.exists()) {
260-
for (File up = parent; up != null && !up.exists(); ) {
261-
parent = up;
262-
up = up.getParentFile();
263-
}
264-
throw new SQLException(
265-
"path to '" + fileName + "': '" + parent + "' does not exist");
266-
}
267-
268-
// check write access if file does not exist
269-
try {
270-
// The extra check to exists() is necessary as createNewFile()
271-
// does not follow the JavaDoc when used on read-only shares.
272-
if (!file.exists() && file.createNewFile()) file.delete();
273-
} catch (Exception e) {
274-
throw new SQLException("opening db: '" + fileName + "': " + e.getMessage());
275-
}
276-
fileName = file.getAbsolutePath();
257+
fileName = new File(fileName).getAbsolutePath();
277258
}
278259
}
279260

src/main/java/org/sqlite/util/OSInfo.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// --------------------------------------
2525
package org.sqlite.util;
2626

27+
import java.io.File;
2728
import java.io.IOException;
2829
import java.nio.file.Files;
2930
import java.nio.file.Path;
@@ -114,7 +115,21 @@ public static String getOSName() {
114115
}
115116

116117
public static boolean isAndroid() {
117-
return isAndroidRuntime() || isAndroidTermux();
118+
return isAndroidRuntime() || isAndroidTermux() || isRunningAndroid();
119+
}
120+
121+
private static boolean isRunningAndroid() {
122+
// This file is guaranteed to be present on every android version since 1.6 (Donut, API 4),
123+
// see https://developer.android.com/ndk/guides/stable_apis#graphics
124+
// We don't use libc/libm/libdl because that has changed what directory its pointing to and
125+
// OEMs implement the symlink that allows backwards compatibility
126+
// for apps that use the old path differently, which may cause this check to fail because
127+
// common undocumented behaviour. See
128+
// https://developer.android.com/about/versions/10/behavior-changes-all#bionic
129+
File androidGLES = new File("/system/lib/libGLESv1_CM");
130+
File android64GLES = new File("/system/lib64/libGLESv1_CM");
131+
132+
return android64GLES.exists() || androidGLES.exists();
118133
}
119134

120135
public static boolean isAndroidRuntime() {
@@ -203,7 +218,7 @@ static String resolveArmArchType() {
203218
}
204219

205220
// Java 1.8 introduces a system property to determine armel or armhf
206-
// http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8005545
221+
// https://bugs.openjdk.org/browse/JDK-8005545
207222
String abi = System.getProperty("sun.arch.abi");
208223
if (abi != null && abi.startsWith("gnueabihf")) {
209224
return "armv7";

src/test/java/org/sqlite/ConnectionTest.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import java.io.FileOutputStream;
77
import java.io.IOException;
88
import java.io.InputStream;
9+
import java.nio.file.AccessDeniedException;
10+
import java.nio.file.Files;
11+
import java.nio.file.Path;
12+
import java.nio.file.Paths;
913
import java.sql.*;
1014
import java.util.ArrayList;
1115
import java.util.Properties;
@@ -14,6 +18,8 @@
1418
import java.util.concurrent.Executors;
1519
import java.util.concurrent.Future;
1620
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.condition.DisabledOnOs;
22+
import org.junit.jupiter.api.condition.OS;
1723
import org.junit.jupiter.api.io.TempDir;
1824
import org.sqlite.SQLiteConfig.JournalMode;
1925
import org.sqlite.SQLiteConfig.Pragma;
@@ -555,4 +561,49 @@ public void settingsBeforeDbCreationConfig() throws Exception {
555561
}
556562
}
557563
}
564+
565+
@Test
566+
public void openNonExistingFileNoCreate() {
567+
Path nonExisting = Paths.get("non_existing.db").toAbsolutePath();
568+
assertThat(Files.exists(nonExisting)).isFalse();
569+
SQLiteConfig cfg = new SQLiteConfig();
570+
cfg.resetOpenMode(SQLiteOpenMode.CREATE);
571+
assertThatExceptionOfType(SQLiteException.class)
572+
.isThrownBy(
573+
() -> {
574+
@SuppressWarnings({"resource", "unused"})
575+
Connection _c = cfg.createConnection("jdbc:sqlite:" + nonExisting);
576+
})
577+
.satisfies(
578+
e ->
579+
assertThat(e.getResultCode())
580+
.isEqualTo(SQLiteErrorCode.SQLITE_CANTOPEN));
581+
assertThat(Files.exists(nonExisting)).isFalse();
582+
}
583+
584+
@DisabledOnOs(OS.WINDOWS) // File.setReadOnly doesn't seem to work here
585+
@Test
586+
public void openNonExistingFileInReadOnlyDirectory(@TempDir Path tmpDir) {
587+
assertThat(tmpDir.toFile().setReadOnly()).isTrue();
588+
assertThat(Files.exists(tmpDir)).isTrue();
589+
Path nonExisting = tmpDir.resolve("non_existing.db").toAbsolutePath();
590+
assertThatThrownBy(() -> Files.createFile(nonExisting))
591+
.isInstanceOf(AccessDeniedException.class);
592+
assertThat(Files.exists(nonExisting)).isFalse();
593+
SQLiteConfig cfg = new SQLiteConfig();
594+
assertThatExceptionOfType(SQLiteException.class)
595+
.isThrownBy(
596+
() -> {
597+
@SuppressWarnings({"resource", "unused"})
598+
Connection _c = cfg.createConnection("jdbc:sqlite:" + nonExisting);
599+
})
600+
.satisfies(
601+
e ->
602+
// It would be nice, if the native error code were more specific on
603+
// why the file can't be
604+
// opened, but this is what we get:
605+
assertThat(e.getResultCode())
606+
.isEqualTo(SQLiteErrorCode.SQLITE_CANTOPEN));
607+
assertThat(Files.exists(nonExisting)).isFalse();
608+
}
558609
}

src/test/java/org/sqlite/util/OSInfoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public void testIsAndroidTermux() throws Exception {
133133
}
134134

135135
@Nested
136-
@SetSystemProperty(key = "java.runtime.name", value = "Java for Android")
137-
@SetSystemProperty(key = "os.name", value = "Linux for Android")
136+
@SetSystemProperty(key = "java.runtime.name", value = "Android Runtime")
137+
@SetSystemProperty(key = "os.name", value = "Linux")
138138
class AndroidRuntime {
139139

140140
@Test
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"comment": "New reachability metadata format introduced in GraalVM for JDK 23, this merges the other *-config.json files into one: https://www.graalvm.org/latest/reference-manual/native-image/metadata/",
3+
"resources": [
4+
{
5+
"glob": "org/sqlite/*.jar"
6+
},
7+
{
8+
"glob": "org/sqlite/*.db"
9+
},
10+
{
11+
"module": "java.sql.rowset",
12+
"glob": "javax/sql/rowset/rowset.properties"
13+
}
14+
],
15+
"bundles": [
16+
{
17+
"name": "com.sun.rowset.RowSetResourceBundle"
18+
}
19+
],
20+
"reflection": [
21+
{
22+
"type": "com.sun.rowset.providers.RIOptimisticProvider",
23+
"methods": [
24+
{
25+
"name": "<init>",
26+
"parameterTypes": []
27+
}
28+
]
29+
},
30+
{
31+
"type": "java.sql.Types",
32+
"allPublicFields": true
33+
}
34+
]
35+
}

0 commit comments

Comments
 (0)