Closes 2 not-closed sets

Add error-handling if the processor wasn't added into the Queue
This commit is contained in:
Fuzzlemann 2017-08-23 14:43:44 +02:00
parent a5d90f092d
commit 68f8159027
2 changed files with 7 additions and 5 deletions

View File

@ -195,7 +195,7 @@ public class CommandUseTable extends Table {
public Optional<String> getCommandByID(int id) throws SQLException {
PreparedStatement statement = null;
ResultSet set;
ResultSet set = null;
try {
statement = prepareStatement(Select.from(tableName, columnCommand).where(columnCommandId + "=?").toString());
statement.setInt(1, id);
@ -206,13 +206,13 @@ public class CommandUseTable extends Table {
return Optional.empty();
} finally {
endTransaction(statement);
close(statement);
close(set, statement);
}
}
public Optional<Integer> getCommandID(String command) throws SQLException {
PreparedStatement statement = null;
ResultSet set;
ResultSet set = null;
try {
statement = prepareStatement(Select.from(tableName, columnCommandId).where(columnCommand + "=?").toString());
statement.setString(1, command);
@ -223,7 +223,7 @@ public class CommandUseTable extends Table {
return Optional.empty();
} finally {
endTransaction(statement);
close(statement);
close(set, statement);
}
}
}

View File

@ -32,7 +32,9 @@ public class ProcessingQueue extends Queue<Processor> {
* @param processor processing object.
*/
public void addToQueue(Processor processor) {
queue.offer(processor);
if (!queue.offer(processor)) {
Log.toLog("ProcessingQueue.addToQueue", new IllegalStateException("Processor was not added to Queue"));
}
}
}