Skip to content

Commit

Permalink
fix: downgrade SLF4J to 1.7
Browse files Browse the repository at this point in the history
Closes: #990
Co-authored-by: Gauthier Roebroeck <gauthier.roebroeck@gmail.com>
  • Loading branch information
vietk and gotson committed Oct 18, 2023
1 parent bccd769 commit 874a926
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $(SQLITE_UNPACKED): $(SQLITE_ARCHIVE)

$(JAVA_CLASSPATH):
@mkdir -p $(@D)
curl -L -f -o$@ https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar
curl -L -f -o$@ https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar

$(TARGET)/common-lib/org/sqlite/%.class: src/main/java/org/sqlite/%.java
@mkdir -p $(@D)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ JAVA_CLASSPATH:=$(TARGET)/classpath/slf4j-api.jar
ifeq ("$(wildcard $(OSINFO_PROG))","")
$(info Building OSInfo tool)
$(shell mkdir -p $(TARGET)/classpath)
$(shell curl -L -f -o$(JAVA_CLASSPATH) https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar)
$(shell curl -L -f -o$(JAVA_CLASSPATH) https://search.maven.org/remotecontent?filepath=org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar)
$(shell $(JAVAC) -cp $(JAVA_CLASSPATH) -sourcepath $(SRC) -d lib src/main/java/org/sqlite/util/OSInfo.java)
endif

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
<version>1.7.36</version>
</dependency>
<!--
This dependency makes compilation on non-GraalVM versions possible.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sqlite/JDBC.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class JDBC implements Driver {
try {
DriverManager.registerDriver(new JDBC());
} catch (SQLException e) {
logger.atError().setCause(e).log();
logger.error("Could not register driver", e);
}
}

Expand Down
30 changes: 12 additions & 18 deletions src/main/java/org/sqlite/SQLiteJDBCLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ static void cleanup() {
try {
Files.delete(nativeLib);
} catch (Exception e) {
logger.atError()
.setCause(e)
.log("Failed to delete old native lib");
logger.error("Failed to delete old native lib", e);
}
}
});
} catch (IOException e) {
logger.atError().setCause(e).log("Failed to open directory");
logger.error("Failed to open directory", e);
}
}

Expand Down Expand Up @@ -224,7 +222,7 @@ private static boolean extractAndLoadLibraryFile(
}
return loadNativeLibrary(targetFolder, extractedLibFileName);
} catch (IOException e) {
logger.atError().setCause(e).log();
logger.error("Unexpected IOException", e);
return false;
}
}
Expand All @@ -248,7 +246,7 @@ private static InputStream getResourceAsStream(String name) {
connection.setUseCaches(false);
return connection.getInputStream();
} catch (IOException e) {
logger.atError().setCause(e).log();
logger.error("Could not connect", e);
return null;
}
}
Expand All @@ -268,12 +266,12 @@ private static boolean loadNativeLibrary(String path, String name) {
System.load(new File(path, name).getAbsolutePath());
return true;
} catch (UnsatisfiedLinkError e) {
logger.atError()
.setCause(e)
.setMessage("Failed to load native library: {}. osinfo: {}")
.addArgument(name)
.addArgument(OSInfo::getNativeLibFolderPathForCurrentOS)
.log();

logger.error(
"Failed to load native library: {}. osinfo: {}",
name,
OSInfo.getNativeLibFolderPathForCurrentOS(),
e);
return false;
}

Expand All @@ -287,9 +285,7 @@ private static boolean loadNativeLibraryJdk() {
System.loadLibrary(LibraryLoaderUtil.NATIVE_LIB_BASE_NAME);
return true;
} catch (UnsatisfiedLinkError e) {
logger.atError()
.setCause(e)
.log("Failed to load native library through System.loadLibrary");
logger.error("Failed to load native library through System.loadLibrary", e);
return false;
}
}
Expand Down Expand Up @@ -422,9 +418,7 @@ public static final class VersionHolder {
// inline creation of logger to avoid build-time initialization of the logging
// framework in native-image
LoggerFactory.getLogger(VersionHolder.class)
.atError()
.setCause(e)
.log("Could not read version from file: {}", versionFile);
.error("Could not read version from file: {}", versionFile, e);
}
VERSION = version;
}
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/org/sqlite/core/NativeDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ protected synchronized void _open(String file, int openFlags) throws SQLExceptio
/** @see org.sqlite.core.DB#_exec(java.lang.String) */
@Override
public synchronized int _exec(String sql) throws SQLException {
logger.atTrace()
.setMessage("DriverManager [{}] [SQLite EXEC] {}")
.addArgument(() -> Thread.currentThread().getName())
.addArgument(sql)
.log();
if (logger.isTraceEnabled()) {
logger.trace(
"DriverManager [{}] [SQLite EXEC] {}", Thread.currentThread().getName(), sql);
}
return _exec_utf8(stringToUtf8ByteArray(sql));
}

Expand Down Expand Up @@ -126,11 +125,10 @@ public synchronized int _exec(String sql) throws SQLException {
/** @see org.sqlite.core.DB#prepare(java.lang.String) */
@Override
protected synchronized SafeStmtPtr prepare(String sql) throws SQLException {
logger.atTrace()
.setMessage("DriverManager [{}] [SQLite EXEC] {}")
.addArgument(() -> Thread.currentThread().getName())
.addArgument(sql)
.log();
if (logger.isTraceEnabled()) {
logger.trace(
"DriverManager [{}] [SQLite EXEC] {}", Thread.currentThread().getName(), sql);
}
return new SafeStmtPtr(this, prepare_utf8(stringToUtf8ByteArray(sql)));
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/sqlite/jdbc3/JDBC3DatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -964,14 +964,14 @@ public ResultSet getColumns(String c, String s, String tblNamePattern, String co
try {
rsColAutoinc.close();
} catch (Exception e) {
LogHolder.logger.atError().setCause(e).log();
LogHolder.logger.error("Could not close ResultSet", e);
}
}
if (statColAutoinc != null) {
try {
statColAutoinc.close();
} catch (Exception e) {
LogHolder.logger.atError().setCause(e).log();
LogHolder.logger.error("Could not close statement", e);
}
}
}
Expand Down Expand Up @@ -1122,7 +1122,7 @@ public ResultSet getColumns(String c, String s, String tblNamePattern, String co
try {
rs.close();
} catch (Exception e) {
LogHolder.logger.atError().setCause(e).log();
LogHolder.logger.error("Could not close ResultSet", e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sqlite/jdbc3/JDBC3Statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static class BackupObserver implements ProgressObserver {
private static final Logger logger = LoggerFactory.getLogger(BackupObserver.class);

public void progress(int remaining, int pageCount) {
logger.atInfo().log("remaining:{}, page count:{}", remaining, pageCount);
logger.info("remaining:{}, page count:{}", remaining, pageCount);
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/sqlite/util/OSInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static String getHardwareName() {
try {
return processRunner.runAndWaitFor("uname -m");
} catch (Throwable e) {
LogHolder.logger.atError().setCause(e).log("Error while running uname -m");
LogHolder.logger.error("Error while running uname -m", e);
return "unknown";
}
}
Expand Down Expand Up @@ -221,10 +221,8 @@ static String resolveArmArchType() {
return "armv7";
}
} else {
LogHolder.logger
.atWarn()
.log(
"readelf not found. Cannot check if running on an armhf system, armel architecture will be presumed");
LogHolder.logger.warn(
"readelf not found. Cannot check if running on an armhf system, armel architecture will be presumed");
}
} catch (IOException | InterruptedException e) {
// ignored: fall back to "arm" arch (soft-float ABI)
Expand Down

0 comments on commit 874a926

Please sign in to comment.