diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java index aa331c2e2..5241e1276 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java @@ -69,7 +69,12 @@ public class PostgreSQLAuthenticationProviderModule implements Module { myBatisProperties.setProperty("JDBC.autoCommit", "false"); myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true"); myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1"); - myBatisProperties.setProperty("mybatis.configuration.defaultStatementTimeout", environment.getPostgreSQLDefaultStatementTimeout()); + + // Only set if > 0. Underlying backend does not take 0 as not-set. + int defaultStatementTimeout = environment.getPostgreSQLDefaultStatementTimeout(); + if(defaultStatementTimeout > 0) { + myBatisProperties.setProperty("mybatis.configuration.defaultStatementTimeout", String.valueOf(defaultStatementTimeout)); + } // Use UTF-8 in database driverProperties.setProperty("characterEncoding", "UTF-8"); diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLEnvironment.java index d7e4daeee..7ce4795ce 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLEnvironment.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLEnvironment.java @@ -51,10 +51,10 @@ public class PostgreSQLEnvironment extends JDBCEnvironment { /** * The default defaultStatementTimeout (in seconds), * if POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT is not specified. - * Default to null (no timeout) + * Default to 0 (no timeout, property won't be set) * https://mybatis.org/mybatis-3/configuration.html */ - private static final String DEFAULT_DEFAULT_STATEMENT_TIMEOUT = "null"; + private static final int DEFAULT_DEFAULT_STATEMENT_TIMEOUT = 0; /** * The default socketTimeout (in seconds), if POSTGRESQL_SOCKET_TIMEOUT is not specified. @@ -267,7 +267,8 @@ public class PostgreSQLEnvironment extends JDBCEnvironment { /** * Returns the defaultStatementTimeout set for PostgreSQL connections. - * If unspecified, this will be the default "null" (no timeout) + * If unspecified, this will be the default 0, + * and should not be passed through to the backend. * * @return * The statement timeout (in seconds) @@ -275,7 +276,7 @@ public class PostgreSQLEnvironment extends JDBCEnvironment { * @throws GuacamoleException * If an error occurs while retrieving the property value. */ - public String getPostgreSQLDefaultStatementTimeout() throws GuacamoleException { + public int getPostgreSQLDefaultStatementTimeout() throws GuacamoleException { return getProperty( PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT, DEFAULT_DEFAULT_STATEMENT_TIMEOUT diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLGuacamoleProperties.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLGuacamoleProperties.java index 128b5c348..feaf85536 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLGuacamoleProperties.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLGuacamoleProperties.java @@ -98,8 +98,8 @@ public class PostgreSQLGuacamoleProperties { * Sets the number of seconds the driver will wait for * a response from the database. */ - public static final StringGuacamoleProperty - POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT = new StringGuacamoleProperty(){ + public static final IntegerGuacamoleProperty + POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT = new IntegerGuacamoleProperty(){ @Override public String getName() { return "postgresql-default-statement-timeout"; }