Skip to content

Commit

Permalink
removed all junk code >:(
Browse files Browse the repository at this point in the history
  • Loading branch information
KweezyCode committed Sep 2, 2024
1 parent 4fa9e6f commit 3b6acef
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 342 deletions.
18 changes: 0 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,6 @@
</profiles>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<!--
This dependency makes compilation on non-GraalVM versions possible.
The dependency should however never actually be required by end-users because if they require
Expand Down Expand Up @@ -461,18 +456,5 @@
<version>5.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>${archunit.version}</version>
<scope>test</scope>
</dependency>
<!-- Required by archunit -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.13</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
4 changes: 1 addition & 3 deletions src/main/java/org/sqlite/JDBC.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
import java.sql.*;
import java.util.Properties;
import java.util.logging.Logger;
import org.slf4j.LoggerFactory;
import org.sqlite.jdbc4.JDBC4Connection;

public class JDBC implements Driver {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(JDBC.class);
public static final String PREFIX = "jdbc:sqlite:";

static {
try {
DriverManager.registerDriver(new JDBC());
} catch (SQLException e) {
logger.error("Could not register driver", e);
System.err.println("Could not register driver" + e);
}
}

Expand Down
25 changes: 10 additions & 15 deletions src/main/java/org/sqlite/SQLiteJDBCLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import java.util.Properties;
import java.util.UUID;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sqlite.util.LibraryLoaderUtil;
import org.sqlite.util.OSInfo;
import org.sqlite.util.StringUtils;
Expand All @@ -57,8 +55,6 @@
* @author leo
*/
public class SQLiteJDBCLoader {
private static final Logger logger = LoggerFactory.getLogger(SQLiteJDBCLoader.class);

private static final String LOCK_EXT = ".lck";
private static boolean extracted = false;

Expand Down Expand Up @@ -101,12 +97,12 @@ static void cleanup() {
try {
Files.delete(nativeLib);
} catch (Exception e) {
logger.error("Failed to delete old native lib", e);
System.err.println("Failed to delete old native lib" + e);
}
}
});
} catch (IOException e) {
logger.error("Failed to open directory", e);
System.err.println("Failed to open directory" + e);
}
}

Expand Down Expand Up @@ -222,7 +218,7 @@ private static boolean extractAndLoadLibraryFile(
}
return loadNativeLibrary(targetFolder, extractedLibFileName);
} catch (IOException e) {
logger.error("Unexpected IOException", e);
System.err.println("Unexpected IOException" + e);
return false;
}
}
Expand All @@ -246,7 +242,7 @@ private static InputStream getResourceAsStream(String name) {
connection.setUseCaches(false);
return connection.getInputStream();
} catch (IOException e) {
logger.error("Could not connect", e);
System.err.println("Could not connect" + e);
return null;
}
}
Expand All @@ -267,10 +263,10 @@ private static boolean loadNativeLibrary(String path, String name) {
return true;
} catch (UnsatisfiedLinkError e) {

logger.error(
"Failed to load native library: {}. osinfo: {}",
name,
OSInfo.getNativeLibFolderPathForCurrentOS(),
System.err.println(
"Failed to load native library: {}. osinfo: {}" +
name +
OSInfo.getNativeLibFolderPathForCurrentOS() +
e);
return false;
}
Expand All @@ -285,7 +281,7 @@ private static boolean loadNativeLibraryJdk() {
System.loadLibrary(LibraryLoaderUtil.NATIVE_LIB_BASE_NAME);
return true;
} catch (UnsatisfiedLinkError e) {
logger.error("Failed to load native library through System.loadLibrary", e);
System.err.println("Failed to load native library through System.loadLibrary" + e);
return false;
}
}
Expand Down Expand Up @@ -417,8 +413,7 @@ public static final class VersionHolder {
} catch (IOException e) {
// inline creation of logger to avoid build-time initialization of the logging
// framework in native-image
LoggerFactory.getLogger(VersionHolder.class)
.error("Could not read version from file: {}", versionFile, e);
System.err.println("Could not read version from file: {}" + versionFile + e);
}
VERSION = version;
}
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/sqlite/core/NativeDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sqlite.BusyHandler;
import org.sqlite.Collation;
import org.sqlite.Function;
Expand All @@ -30,7 +28,6 @@

/** This class provides a thin JNI layer over the SQLite3 C API. */
public final class NativeDB extends DB {
private static final Logger logger = LoggerFactory.getLogger(NativeDB.class);
private static final int DEFAULT_BACKUP_BUSY_SLEEP_TIME_MILLIS = 100;
private static final int DEFAULT_BACKUP_NUM_BUSY_BEFORE_FAIL = 3;
private static final int DEFAULT_PAGES_PER_BACKUP_STEP = 100;
Expand Down Expand Up @@ -90,10 +87,6 @@ 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 {
if (logger.isTraceEnabled()) {
logger.trace(
"DriverManager [{}] [SQLite EXEC] {}", Thread.currentThread().getName(), sql);
}
return _exec_utf8(stringToUtf8ByteArray(sql));
}

Expand Down Expand Up @@ -125,10 +118,6 @@ 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 {
if (logger.isTraceEnabled()) {
logger.trace(
"DriverManager [{}] [SQLite EXEC] {}", Thread.currentThread().getName(), sql);
}
return new SafeStmtPtr(this, prepare_utf8(stringToUtf8ByteArray(sql)));
}

Expand Down
16 changes: 3 additions & 13 deletions src/main/java/org/sqlite/jdbc3/JDBC3DatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sqlite.SQLiteConnection;
import org.sqlite.core.CoreDatabaseMetaData;
import org.sqlite.core.CoreStatement;
Expand Down Expand Up @@ -964,14 +962,14 @@ public ResultSet getColumns(String c, String s, String tblNamePattern, String co
try {
rsColAutoinc.close();
} catch (Exception e) {
LogHolder.logger.error("Could not close ResultSet", e);
System.err.println("Could not close ResultSet" + e);
}
}
if (statColAutoinc != null) {
try {
statColAutoinc.close();
} catch (Exception e) {
LogHolder.logger.error("Could not close statement", e);
System.err.println("Could not close statement" + e);
}
}
}
Expand Down Expand Up @@ -1125,7 +1123,7 @@ public ResultSet getColumns(String c, String s, String tblNamePattern, String co
try {
rs.close();
} catch (Exception e) {
LogHolder.logger.error("Could not close ResultSet", e);
System.err.println("Could not close ResultSet" + e);
}
}
}
Expand Down Expand Up @@ -2242,12 +2240,4 @@ private String unquoteIdentifier(String name) {
}
return name;
}

/**
* Class-wrapper around the logger object to avoid build-time initialization of the logging
* framework in native-image
*/
private static class LogHolder {
private static final Logger logger = LoggerFactory.getLogger(JDBC3DatabaseMetaData.class);
}
}
6 changes: 1 addition & 5 deletions src/main/java/org/sqlite/jdbc3/JDBC3Statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sqlite.ExtendedCommand;
import org.sqlite.ExtendedCommand.SQLExtension;
import org.sqlite.SQLiteConnection;
Expand Down Expand Up @@ -97,10 +95,8 @@ public ResultSet executeQuery(String sql) throws SQLException {
}

static class BackupObserver implements ProgressObserver {
private static final Logger logger = LoggerFactory.getLogger(BackupObserver.class);

public void progress(int remaining, int pageCount) {
logger.info("remaining:{}, page count:{}", remaining, pageCount);
System.out.println("remaining: " + remaining + ", page count: " + pageCount);
}
}

Expand Down
14 changes: 2 additions & 12 deletions src/main/java/org/sqlite/util/OSInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Provides OS name and architecture name.
Expand Down Expand Up @@ -163,7 +161,7 @@ static String getHardwareName() {
try {
return processRunner.runAndWaitFor("uname -m");
} catch (Throwable e) {
LogHolder.logger.error("Error while running uname -m", e);
System.err.println("Error while running uname -m" + e);
return "unknown";
}
}
Expand Down Expand Up @@ -230,7 +228,7 @@ static String resolveArmArchType() {
return "armv7";
}
} else {
LogHolder.logger.warn(
System.out.println(
"readelf not found. Cannot check if running on an armhf system, armel architecture will be presumed");
}
} catch (IOException | InterruptedException e) {
Expand Down Expand Up @@ -279,12 +277,4 @@ static String translateOSNameToFolderName(String osName) {
static String translateArchNameToFolderName(String archName) {
return archName.replaceAll("\\W", "");
}

/**
* Class-wrapper around the logger object to avoid build-time initialization of the logging
* framework in native-image
*/
private static class LogHolder {
private static final Logger logger = LoggerFactory.getLogger(OSInfo.class);
}
}
1 change: 0 additions & 1 deletion src/main/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module org.xerial.sqlitejdbc {

requires org.slf4j;
requires transitive java.sql;
requires transitive java.sql.rowset;
requires static org.graalvm.nativeimage;
Expand Down
Loading

0 comments on commit 3b6acef

Please sign in to comment.