aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/elytrium/limboauth/dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/elytrium/limboauth/dependencies')
-rw-r--r--src/main/java/net/elytrium/limboauth/dependencies/BaseLibrary.java14
-rw-r--r--src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java23
2 files changed, 22 insertions, 15 deletions
diff --git a/src/main/java/net/elytrium/limboauth/dependencies/BaseLibrary.java b/src/main/java/net/elytrium/limboauth/dependencies/BaseLibrary.java
index 6e1b11f..5c864be 100644
--- a/src/main/java/net/elytrium/limboauth/dependencies/BaseLibrary.java
+++ b/src/main/java/net/elytrium/limboauth/dependencies/BaseLibrary.java
@@ -18,6 +18,7 @@
package net.elytrium.limboauth.dependencies;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -66,14 +67,11 @@ public enum BaseLibrary {
this.filenamePath = Path.of("libraries/" + mavenPath);
- URL mavenRepoURL = null;
try {
- mavenRepoURL = new URL("https://repo1.maven.org/maven2/" + mavenPath);
- } catch (Exception e) {
- e.printStackTrace();
+ this.mavenRepoURL = new URL("https://repo1.maven.org/maven2/" + mavenPath);
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(e);
}
-
- this.mavenRepoURL = mavenRepoURL;
}
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
@@ -84,8 +82,8 @@ public enum BaseLibrary {
Files.createDirectories(this.filenamePath.getParent());
Files.copy(in, Files.createFile(this.filenamePath), StandardCopyOption.REPLACE_EXISTING);
}
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
}
}
diff --git a/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java b/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java
index 6e416f8..ea78f61 100644
--- a/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java
+++ b/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java
@@ -19,14 +19,17 @@ package net.elytrium.limboauth.dependencies;
import com.j256.ormlite.jdbc.JdbcSingleConnectionSource;
import com.j256.ormlite.support.ConnectionSource;
+import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
+import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
@@ -90,23 +93,27 @@ public enum DatabaseLibrary {
this.stringGetter = stringGetter;
}
- public Connection connect(ClassLoader classLoader, Path dir, String hostname, String database, String user, String password) throws Exception {
+ public Connection connect(ClassLoader classLoader, Path dir, String hostname, String database, String user, String password)
+ throws ReflectiveOperationException, SQLException, IOException {
return this.connect(classLoader, dir, this.stringGetter.getJdbcString(dir, hostname, database), user, password);
}
- public Connection connect(Path dir, String hostname, String database, String user, String password) throws Exception {
+ public Connection connect(Path dir, String hostname, String database, String user, String password)
+ throws ReflectiveOperationException, SQLException, IOException {
return this.connect(dir, this.stringGetter.getJdbcString(dir, hostname, database), user, password);
}
- public Connection connect(ClassLoader classLoader, Path dir, String jdbc, String user, String password) throws Exception {
+ public Connection connect(ClassLoader classLoader, Path dir, String jdbc, String user, String password)
+ throws ReflectiveOperationException, SQLException, IOException {
return this.connector.connect(classLoader, dir, jdbc, user, password);
}
- public Connection connect(Path dir, String jdbc, String user, String password) throws Exception {
+ public Connection connect(Path dir, String jdbc, String user, String password) throws IOException, ReflectiveOperationException, SQLException {
return this.connector.connect(new IsolatedClassLoader(new URL[]{this.baseLibrary.getClassLoaderURL()}), dir, jdbc, user, password);
}
- public ConnectionSource connectToORM(Path dir, String hostname, String database, String user, String password) throws Exception {
+ public ConnectionSource connectToORM(Path dir, String hostname, String database, String user, String password)
+ throws ReflectiveOperationException, IOException, SQLException, URISyntaxException {
String jdbc = this.stringGetter.getJdbcString(dir, hostname, database);
URL baseLibraryURL = this.baseLibrary.getClassLoaderURL();
ClassLoader currentClassLoader = DatabaseLibrary.class.getClassLoader();
@@ -117,7 +124,8 @@ public enum DatabaseLibrary {
return new JdbcSingleConnectionSource(jdbc, this.connect(currentClassLoader, dir, jdbc, user, password));
}
- private static Connection fromDriver(Class<?> connectionClass, String jdbc, String user, String password, boolean register) throws Exception {
+ private static Connection fromDriver(Class<?> connectionClass, String jdbc, String user, String password, boolean register)
+ throws ReflectiveOperationException, SQLException {
Constructor<?> legacyConstructor = connectionClass.getConstructor();
Properties info = new Properties();
@@ -142,7 +150,8 @@ public enum DatabaseLibrary {
}
public interface DatabaseConnector {
- Connection connect(ClassLoader classLoader, Path dir, String jdbc, String user, String password) throws Exception;
+ Connection connect(ClassLoader classLoader, Path dir, String jdbc, String user, String password)
+ throws ReflectiveOperationException, SQLException, IOException;
}
public interface DatabaseStringGetter {