mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +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("JDBC.autoCommit", "false");
|
||||||
myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true");
|
myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true");
|
||||||
myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1");
|
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
|
// Use UTF-8 in database
|
||||||
driverProperties.setProperty("characterEncoding", "UTF-8");
|
driverProperties.setProperty("characterEncoding", "UTF-8");
|
||||||
|
@@ -51,10 +51,10 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
|
|||||||
/**
|
/**
|
||||||
* The default defaultStatementTimeout (in seconds),
|
* The default defaultStatementTimeout (in seconds),
|
||||||
* if POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT is not specified.
|
* 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
|
* 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.
|
* 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.
|
* 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
|
* @return
|
||||||
* The statement timeout (in seconds)
|
* The statement timeout (in seconds)
|
||||||
@@ -275,7 +276,7 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs while retrieving the property value.
|
* If an error occurs while retrieving the property value.
|
||||||
*/
|
*/
|
||||||
public String getPostgreSQLDefaultStatementTimeout() throws GuacamoleException {
|
public int getPostgreSQLDefaultStatementTimeout() throws GuacamoleException {
|
||||||
return getProperty(
|
return getProperty(
|
||||||
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT,
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT,
|
||||||
DEFAULT_DEFAULT_STATEMENT_TIMEOUT
|
DEFAULT_DEFAULT_STATEMENT_TIMEOUT
|
||||||
|
@@ -98,8 +98,8 @@ public class PostgreSQLGuacamoleProperties {
|
|||||||
* Sets the number of seconds the driver will wait for
|
* Sets the number of seconds the driver will wait for
|
||||||
* a response from the database.
|
* a response from the database.
|
||||||
*/
|
*/
|
||||||
public static final StringGuacamoleProperty
|
public static final IntegerGuacamoleProperty
|
||||||
POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT = new StringGuacamoleProperty(){
|
POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT = new IntegerGuacamoleProperty(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "postgresql-default-statement-timeout"; }
|
public String getName() { return "postgresql-default-statement-timeout"; }
|
||||||
|
Reference in New Issue
Block a user