Uploaded image for project: 'Agroal'
  1. Agroal
  2. AG-288

Impossible to set login timeout when using AgroalDataSource

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 3.1
    • 3.0
    • pool
    • None

      I'm using io.agroal.springframework.boot.AgroalDataSource to set up multiple data sources with Agroal and Narayana.

      I found out that it's impossible to set the login timeout:

      • if you call setLoginTimeout at configuration time (i.e.: before the bean is initialized), it fails with NullPointerException, because the delegate is not yet instantiated
      • if you call it after the delegate has been instantiated, it will be a no-op, since io.agroal.pool.DataSource.setLoginTimeout(int) does nothing

      In my opinion:

      • if the delegate is not yet ready, io.agroal.springframework.boot.AgroalDataSource.setLoginTimeout(int) should set its value into the connectionFactoryConfiguration
      • in order to support changing the login timeout dynamically, io.agroal.pool.DataSource.setLoginTimeout(int) should set it on the Pool, which should implement a new function to pass this information to the ConnectionFactory which may then pass this information in turn to the dataSource or xaDataSource it is backed with

      The second point is probably a bit of work, however the first one should be quite straightforward. Unfortunately it's impossible to bypass this by extending io.agroal.springframework.boot.AgroalDataSource because all the configuration objects are private and there's no getter.

      As a very similar problem: the autodetection of the driver class name, which is done by io.agroal.springframework.boot.AgroalDataSource#getDriverClassName, is almost useless: it requires the delegate to be instantiated, which means that it's too late to do the autodetection for instantiating the delegate. I would also say that, as it's currently implemented, it does not support the case in which the returned class name should be an XADataSource implementation. At least this is in some way fixable by extending io.agroal.springframework.boot.AgroalDataSource, although it's not trivial because, again, all configuration objects are private and getUrl() itself only works if the delegate has already been created.

              lbarreiro-1 Luis Barreiro
              mauromol Mauro Molinari
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: