[CONJ-649] datasource connectTimeout URL parameter is not honoured Created: 2018-09-27  Updated: 2019-02-08  Resolved: 2018-12-21

Status: Closed
Project: MariaDB Connector/J
Component/s: configuration
Affects Version/s: 2.3.0, 2.2.3
Fix Version/s: 1.8.0, 2.4.0

Type: Bug Priority: Major
Reporter: Brendon Abbott Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Java 8



 Description   

Configuring the MariaDbDataSource using a URL, the connectTimeout parameter is no longer honoured. The inbuilt default appears to be using.

We configure the connectTimeout to be short, as we are using the JDBC library from within a monitoring application, that requires a non typical, short connectTimeout.
Full config URL is

MariaDbDataSource ds = new MariaDbDataSource("jdbc:mysql://" + dbServer + "/?connectTimeout=3000&socketTimeout=5000");

This appears to have been introduced around commit fde60c15d2aa6d283474ce0c31c24b88a2e78a55
relating to "Pool datasource implementation". CONJ-522



 Comments   
Comment by Brendon Abbott [ 2018-09-27 ]

I did have an attempt to fix, but realised the effect might be far reaching in terms of resilience models, and pooling - so thought best not to!

In MariaDbDataSource.initialize, it feels like line 515 is incorrect behaviour. Unlilke user/password/database it is given a default value in the class. Therefore it is not possible to determine if the client has supplied a value. I tried to put a line after 517, the parsing and only set the default in the UrlParser.Options if it hadn't been read in - however I then discovered the code in Options where it checks Driver Manager

    public int connectTimeout = DriverManager.getLoginTimeout() > 0 ? DriverManager.getLoginTimeout() * 1000 : 30_000;

Generated at Thu Feb 08 03:17:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.