Hikaricp: HikariConfig.copyStateTo copies the value of "sealed" field

Created on 12 Jan 2018  ·  2Comments  ·  Source: brettwooldridge/HikariCP

Environment

HikariCP version: 2.7.5
JDK version     : 1.8.0_152
Database        : PostgreSQL
Driver version  : 42.1.4

After updating to 2.7.5 we noticed our application fail to boot successfully as a result of the changes made to "seal" the HikariConfig / HikariDataSource. I'm not opposed to the approach, but unfortunately the "sealed" value is copied between configs when HikariConfig.copyStateTo(HikariConfig other) is called.

Our use case essentially was to initialize a quartz scheduler HikariPool off of the primary database pool with something like:

public static HikariDataSource createQuartzPool(HikariDataSource primaryDB, SchedulerConfig schedulerConfig) {
  HikariConfig poolConfig = new HikariConfig();
  primaryDB.copyStateTo(poolConfig);

  poolConfig.setPoolName("quartz-pool"); // << this line now throws since 'sealed' is set
  poolConfig.setReadOnly(schedulerConfig.isReadOnly());
  // ... omitted, but other single overrides from SchedulerConfig are set on poolConfig
  return new HikariDataSource(poolConfig);
}

Most helpful comment

@pettyjamesm HikariCP v2.7.6 has been published, containing a fix just for you. 🎉

All 2 comments

Good catch. Looks like we need a unit test to cover this new behavior. I’ll figure out how to allow copy of a sealed configuration in such a way that the copy is not sealed.

Or if you think you have a handle on it, pull requests are welcome.

@pettyjamesm HikariCP v2.7.6 has been published, containing a fix just for you. 🎉

Was this page helpful?
0 / 5 - 0 ratings