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

Inconsistent AgroalDataSource driverClassName setter/getter pair

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Major Major
    • None
    • 3.0
    • spring
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      Consider this:

      AgroalDataSource ds = new AgroalDataSource();
      ds.setUrl("jdbc:h2:mem:foo");
      ds.setDriverClassName("org.h2.jdbcx.JdbcDataSource"); // I want to use XA
      assert ds.getDriverClassName().equals("org.h2.jdbcx.JdbcDataSource")
      

      This fails, because ds.getDriverClassName() returns "org.h2.Driver" (autodetected from URL).
      This is really unexpected, also because I find no way to then get what was actually set as the driver class name.
      I found AG-234 and I guess this came from the desire to support a relaxed reflection contract used by the standard Spring Boot DataSourceBuilder class, but I guess a better solution for this exists. Maybe a distinct pair of setXaDriverClassName/getXaDriverClassName could be provided?

      At least the Javadoc of getDriverClassName() should clearly state that it's not supposed to return what was specified as setDriverClassName() in case of XA.

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

                Created:
                Updated:
                Resolved: