[java-plugin-storage-jdbc] branch main updated: OSJ-342 Investigate Strategies to end of life our use of Hibernate in V5
Rod Widdowson
rdw at steadingsoftware.com
Tue May 24 19:06:01 UTC 2022
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-plugin-storage-jdbc.
View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-storage-jdbc.git;a=commit;h=23089e7c3d6bd6f4b257da33c2c32a7d1dc75bbf
The following commit(s) were added to refs/heads/main by this push:
new 23089e7 OSJ-342 Investigate Strategies to end of life our use of Hibernate in V5
23089e7 is described below
commit 23089e7c3d6bd6f4b257da33c2c32a7d1dc75bbf
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue May 24 20:05:32 2022 +0100
OSJ-342 Investigate Strategies to end of life our use of Hibernate in V5
https://shibboleth.atlassian.net/browse/OSJ-342
Stylistic changes motuicated by the IDP-1951 changes
---
.../storage/jdbc/impl/JDBCStorageService.java | 31 +++++++++++++---------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
index df2eafc..b28fac5 100644
--- a/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
+++ b/jdbc-storage-impl/src/main/java/net/shibboleth/plugin/storage/jdbc/impl/JDBCStorageService.java
@@ -24,6 +24,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -118,6 +119,9 @@ public final class JDBCStorageService extends AbstractStorageService implements
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(JDBCStorageService.class);
+ /** Timeout of SQL queries. */
+ @Nonnull private Duration queryTimeout;
+
/** How many times do we try an operation before giving up? */
private int transactionRetry = 3;
@@ -249,10 +253,11 @@ public final class JDBCStorageService extends AbstractStorageService implements
/** Set the parameter that will be passed to {@link Connection#setTransactionIsolation(int)}.
* @param what the value to set
*/
- public void setTransactionIsolation(int what) {
- Constraint.isTrue(what == Connection.TRANSACTION_NONE ||
- what == Connection.TRANSACTION_READ_COMMITTED || what == Connection.TRANSACTION_READ_UNCOMMITTED ||
- what == Connection.TRANSACTION_REPEATABLE_READ || what == Connection.TRANSACTION_SERIALIZABLE,
+ public void setTransactionIsolation(final int what) {
+ Constraint.isTrue(what == Connection.TRANSACTION_READ_COMMITTED ||
+ what == Connection.TRANSACTION_READ_UNCOMMITTED ||
+ what == Connection.TRANSACTION_REPEATABLE_READ ||
+ what == Connection.TRANSACTION_SERIALIZABLE,
"Invalid value for TransactionIsolation");
transactionIsolation = what;
}
@@ -1067,12 +1072,12 @@ public final class JDBCStorageService extends AbstractStorageService implements
private class ConnectionWithLock implements AutoCloseable {
/** The connection we set up. */
- @Nonnull final Connection connection;
+ @Nonnull private final Connection connection;
/** The lock we may or may not have set up. */
- @Nullable final Lock threadLock;
+ @Nullable private final Lock threadLock;
- /**
+ /** Constructor.
* @param autoCommit
* @param writeLock
* @throws SQLException
@@ -1093,13 +1098,15 @@ public final class JDBCStorageService extends AbstractStorageService implements
}
}
- /** Delegated operation to the encapsulated {@link Connection}.
- * @param Sql what to prepare
+ /** Delegated operation to the encapsulated {@link Connection}.
+ * @param sql what to prepare
* @return what the encapsulated {@link Connection} returns
* @throws SQLException if encapsulated {@link Connection} does
*/
- public PreparedStatement prepareStatement(final String Sql) throws SQLException {
- return connection.prepareStatement(Sql);
+ public PreparedStatement prepareStatement(final String sql) throws SQLException {
+ final PreparedStatement statement = connection.prepareStatement(sql);
+ statement.setQueryTimeout((int) queryTimeout.toSeconds());
+ return statement;
}
/** Delegated operation to the encapsulated {@link Connection}.
@@ -1113,7 +1120,7 @@ public final class JDBCStorageService extends AbstractStorageService implements
public void close() {
try {
connection.close();
- } catch (SQLException e) {
+ } catch (final SQLException e) {
log.error("Auto close failed", e);
}
if (threadLock != null) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list