Java-11 + HikariCP-3.4.1 pool sealed issue

1,707 views
Skip to first unread message

piyush kanungo

unread,
Dec 20, 2019, 6:49:03 AM12/20/19
to HikariCP

Environment : windows


HikariCP version : 3.4.1
JDK version : 11.0.4+10-LTS
Database : SAP SQL Anywhere 17 - 17.0.4.2053
Driver version : jconn4-16.0_SP03_b28836.jar

We are migrating from java-7 to java-11. besides other dependencies, we have upgraded the driver and hikari-cp as above. However, at run time, we are getting below connection pool issue :
java.lang.IllegalStateException: The configuration of the pool is sealed once started. Use HikariConfigMXBean for runtime changes.
at com.zaxxer.hikari.HikariConfig.checkIfSealed(HikariConfig.java:1015)
at com.zaxxer.hikari.HikariConfig.setTransactionIsolation(HikariConfig.java:839)
at *common.service.dsfactory.DataSourceFactory.createDataSource(DataSourceFactory.java:93)
at *common.service.dsfactory.DataSourceFactory.createDataSource(DataSourceFactory.java:50)
at *.ApplicationContext.getDataSource(ApplicationContext.java:160)
at *.ApplicationContextFactory.augmentApplicationContext(ApplicationContextFactory.java:91)
at *.InitBasicsThread.run(InitBasicsThread.java:91)

Brett Wooldridge

unread,
Dec 20, 2019, 7:22:25 AM12/20/19
to HikariCP
This protection was added because there was large misunderstanding of how the pool configuration worked.  Some users thought they could set pool parameters, for example maxPoolSize, then create the HikariDataSource, and after that change the maxPoolSize.  They expected the pool to then adjust.  That is not the case.

So, once you create a HikariDataSource, the configuration is sealed.  Trying to modify parameters after the configuration is sealed will encounter the exception that you encountered.  The only way to modify configuration after the pool has started is through the HikariConfigMXBean.

-Brett

piyush kanungo

unread,
Dec 21, 2019, 1:30:50 AM12/21/19
to HikariCP
Hi Brett,

Thanks for the update.

HikariConfig config = new HikariConfig();
         config.setJdbcUrl(props.getDataSourceURL());
         config.setUsername(user);
         config.setPassword(password);
         HikariDataSource datasource = new HikariDataSource(config);
         datasource.setTransactionIsolation("TRANSACTION_READ_COMMITTED");

We were setting the isolation level after creating the datasource that is the reason got error. Moved the same before datasource creation and used HikariConfig class's method "config.setTransactionIsolation("TRANSACTION_READ_COMMITTED");". This worked!!!
Reply all
Reply to author
Forward
0 new messages