SOLR-14205 Do not fail when given timeout to connectionImpl.isValid() = 0

Closes #1204

Signed-off-by: Kevin Risden <krisden@apache.org>
This commit is contained in:
Nick Vercammen 2020-01-22 19:58:27 +01:00 committed by Kevin Risden
parent 9b6fc1b9fc
commit 60a2926546
No known key found for this signature in database
GPG Key ID: 040FAE3292C5F73F
3 changed files with 9 additions and 1 deletions

View File

@ -242,6 +242,8 @@ Bug Fixes
* SOLR-14196: AdminUI login not working for JWTAuth when blockUnknown=false (janhoy) * SOLR-14196: AdminUI login not working for JWTAuth when blockUnknown=false (janhoy)
* SOLR-14205: Do not fail when given timeout to connectionImpl.isValid() = 0 (Nick Vercammen via Kevin Risden)
Other Changes Other Changes
--------------------- ---------------------

View File

@ -335,7 +335,11 @@ class ConnectionImpl implements Connection {
// check that the connection isn't closed and able to connect within the timeout // check that the connection isn't closed and able to connect within the timeout
try { try {
if(!isClosed()) { if(!isClosed()) {
this.client.connect(timeout, TimeUnit.SECONDS); if (timeout == 0) {
this.client.connect();
} else {
this.client.connect(timeout, TimeUnit.SECONDS);
}
return true; return true;
} }
} catch (InterruptedException|TimeoutException ignore) { } catch (InterruptedException|TimeoutException ignore) {

View File

@ -496,6 +496,8 @@ public class JdbcTest extends SolrCloudTestCase {
private void testJDBCMethods(String collection, String connectionString, Properties properties, String sql) throws Exception { private void testJDBCMethods(String collection, String connectionString, Properties properties, String sql) throws Exception {
try (Connection con = DriverManager.getConnection(connectionString, properties)) { try (Connection con = DriverManager.getConnection(connectionString, properties)) {
assertTrue(con.isValid(DEFAULT_CONNECTION_TIMEOUT)); assertTrue(con.isValid(DEFAULT_CONNECTION_TIMEOUT));
assertTrue("connection should be valid when checked with timeout = 0 -> con.isValid(0)", con.isValid(0));
assertEquals(zkHost, con.getCatalog()); assertEquals(zkHost, con.getCatalog());
con.setCatalog(zkHost); con.setCatalog(zkHost);