remove ThreadDeath and QueueException

main
Jörg Prante 1 month ago
parent 07b20d8188
commit f7fd2df016

@ -19,7 +19,7 @@ jar {
tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.jvmArgs += ['-Duser.language=en','-Duser.country=US']
options.compilerArgs << '-Xlint:all'
options.compilerArgs << '-Xlint:all,-exports'
options.encoding = 'UTF-8'
}

@ -4,7 +4,7 @@ import org.xbib.jdbc.postgresql.Postgresql;
module org.xbib.jdbc.postgresql {
requires org.xbib.jdbc.query;
requires java.sql;
requires org.postgresql.jdbc;
requires org.postgresql.jdbc; // automatic module
uses Flavor;
exports org.xbib.jdbc.postgresql;
provides Flavor with Postgresql;

@ -35,6 +35,7 @@ public class Listener implements Runnable {
while (true) {
try (Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1")) {
//
} catch (SQLException e) {
errorConsumer.accept(e);
}

@ -550,7 +550,10 @@ public class DatabaseImpl implements Database {
}
@Override
public void consumeQueue(String table, String channel, int limit, Consumer<String> consumer) throws SQLException {
public void consumeQueue(String table,
String channel,
int limit,
Consumer<String> consumer) throws SQLException {
List<Long> consumedKeys = new ArrayList<>();
try {
connection.setAutoCommit(false);
@ -563,13 +566,12 @@ public class DatabaseImpl implements Database {
consumer.accept(resultSet.getString("data"));
}
succeedInQueue(connection, table, key);
} catch (QueueException e) {
} catch (Exception e) {
connection.rollback();
failInQueue(connection, table, key);
throw e;
}
}
} finally {
connection.commit();
}
} catch (Exception e) {

@ -170,7 +170,7 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
try {
code.run(this);
complete = true;
} catch (ThreadDeath | DatabaseException t) {
} catch (DatabaseException t) {
throw t;
} catch (Throwable t) {
throw new DatabaseException("Error during transaction", t);
@ -188,7 +188,7 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
try {
code.run(this);
complete = true;
} catch (ThreadDeath | DatabaseException t) {
} catch (DatabaseException t) {
throw t;
} catch (Throwable t) {
throw new DatabaseException("Error during transaction", t);
@ -207,7 +207,7 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
try {
result = code.run(this);
complete = true;
} catch (ThreadDeath | DatabaseException t) {
} catch (DatabaseException t) {
throw t;
} catch (Throwable t) {
throw new DatabaseException("Error during transaction", t);
@ -227,7 +227,7 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
try {
result = code.run(this);
complete = true;
} catch (ThreadDeath | DatabaseException t) {
} catch (DatabaseException t) {
throw t;
} catch (Throwable t) {
throw new DatabaseException("Error during transaction", t);
@ -249,7 +249,7 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
try {
code.run(this, tx);
complete = true;
} catch (ThreadDeath | DatabaseException t) {
} catch (DatabaseException t) {
throw t;
} catch (Throwable t) {
throw new DatabaseException("Error during transaction", t);
@ -270,7 +270,7 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
try {
code.run(this, tx);
complete = true;
} catch (ThreadDeath | DatabaseException t) {
} catch (DatabaseException t) {
throw t;
} catch (Throwable t) {
throw new DatabaseException("Error during transaction", t);
@ -299,7 +299,7 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
// Don't try to be clever about clearing it conditionally.
if (!builder.options.flavor().isAutoCommitOnly()) {
connection.setAutoCommit(false);
metric.checkpoint("setAutoCommit");
metric.checkpoint("setAutoCommit false");
}
} catch (SQLException e) {
throw new DatabaseException("Unable to set autoCommit for the connection", e);
@ -402,9 +402,9 @@ public final class DatabaseProvider implements Supplier<Database>, Closeable {
logger.log(Level.SEVERE, "Unable to close the database connection", e);
}
}
builder.close();
connection = null;
database = null;
builder.close();
}
private static class DatabaseProviderBuilderImpl implements DatabaseProviderBuilder, Closeable {

@ -1,8 +0,0 @@
package org.xbib.jdbc.query;
public class QueueException extends DatabaseException {
public QueueException(String message, Throwable cause) {
super(message, cause);
}
}
Loading…
Cancel
Save