mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-919: make defaultStatementTimeout an int
More consistent with how socketTimeout. MyBatis documentation says only positive integers are valid, and property should not be set otherwise. So in the case of 0 the property will not be set.
This commit is contained in:
@@ -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");
|
||||
|
@@ -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
|
||||
|
@@ -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"; }
|
||||
|
Reference in New Issue
Block a user