[java-plugin-storage-jdbc] branch main updated: JJDBC-31 Setter method for query timeout in JDBCStorageService

Rod Widdowson rdw at steadingsoftware.com
Fri Mar 21 16:13:05 UTC 2025


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=7dc809f0b3b89eb66a47d14ed3f5f83c05db2069

The following commit(s) were added to refs/heads/main by this push:
     new 7dc809f  JJDBC-31 Setter method for query timeout in JDBCStorageService
7dc809f is described below

commit 7dc809f0b3b89eb66a47d14ed3f5f83c05db2069
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Mar 21 16:12:01 2025 +0000

    JJDBC-31 Setter method for query timeout in JDBCStorageService
    
    https://shibboleth.atlassian.net/issues/JJDBC-31
---
 .../plugin/storage/jdbc/impl/JDBCStorageService.java    | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 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 8ef3c4c..e861923 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
@@ -125,6 +125,8 @@ public final class JDBCStorageService extends AbstractStorageService
     static final String DEFAULT_GET_CONTEXT_KEYS_WITH_PREFIX_SQL =
             "SELECT id FROM StorageRecords WHERE context=? AND id like ? AND (expires IS NULL OR expires > ?)";
 
+    /** Default timeout of SQL queries. */
+    static final Duration DEFAULT_QUERY_TIMEOUT = Duration.ofSeconds(5);
 
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(JDBCStorageService.class);
@@ -256,9 +258,8 @@ public final class JDBCStorageService extends AbstractStorageService
      * Set the defaults so that they can be over-ridden by Spring.
      */
     public JDBCStorageService() {
-        final Duration fiveSecs = Duration.ofSeconds(5);
-        assert fiveSecs != null;
-        queryTimeout = fiveSecs;
+        assert DEFAULT_QUERY_TIMEOUT != null;
+        queryTimeout = DEFAULT_QUERY_TIMEOUT;
         setContextSize(JDBCStorageRecord.CONTEXT_SIZE);
         setKeySize(JDBCStorageRecord.KEY_SIZE);
         setValueSize(Integer.MAX_VALUE);
@@ -448,10 +449,18 @@ public final class JDBCStorageService extends AbstractStorageService
      * @since 2.0.0
      */
     public void setGetContextKeysSQL(@Nonnull @NotEmpty final String what) {
-        this.getContextKeysSQL = Constraint.isNotNull(StringSupport.trimOrNull(what),
+        getContextKeysSQL = Constraint.isNotNull(StringSupport.trimOrNull(what),
                 "GetContextKeysSQL cannot be null or empty");
     }
 
+    /** Set the timeout applied via {@link PreparedStatement#setQueryTimeout(int)}.
+     * @param what the timeout to set
+     * @since 2.1.0
+     */
+    public void setQueryTimeout(@Nonnull Duration what) {
+        queryTimeout = Constraint.isNotNull(what, "QueryTimeout should be non null");
+    }
+
     /** {@inheritDoc} */
     protected void doInitialize() throws ComponentInitializationException {
         Constraint.isNotNull(dataSource, "data source must be specified and non-null");

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list