Closed YotillaAntoni closed 1 week ago
If someone provides a pull request with a fix and a unit test, I will be happy to merge it.
If someone provides a pull request with a fix and a unit test, I will be happy to merge it.
@lfbayer I created https://github.com/brettwooldridge/HikariCP/pull/2133.
Thanks @quaff . Any chance this gets merged?
Thanks @quaff . Any chance this gets merged?
I don't know, It seems this project is not active.
We run into a similar issue to https://github.com/brettwooldridge/HikariCP/issues/1489 so we were using the
SQLExceptionOverride
mechanism to avoid the eviction of a connection in some circumstancesBut in some scenarios a
ClassNotFoundException
is thrown when creating aHikariDataSource
after having defined a validHikariConfig
setting anexceptionOverrrideClassName
When the class name of the override handler is set via
HikariConfig.setExceptionOverrideClassName
to validate the input aloadClass
is attempted using the Thread Context ClassLoader. (HikariConfig
line 875)When this validated configuration is used to create a DataSource, and the
PoolBase
is instantiated, it attemps to load the class name for theexceptionOverrride
field, using theUtilityElf.createInstance(...)
method.But the
UtilityElf
doesn't use the Thread Context ClassLoader, but the ClassLoader used to load itself (UtilityElf
line 93):When the HikariCP library is at a higher class loader, like a application container ClassLoader, and the application using it is at "lower" class loader, like a typical WebApp ClassLoader for a WAR, it's not possible to use an application class as
SQLExceptionOverride
.Setting the className in the
HikariCofig
will work, because to check the validity of the className it uses the Thread Context Class Loader, but after that the instantiation ofPoolBase
will failIMO the solution should be change
UtilityElf
line 93 for:In case this isn't possible, for whatever reason, then the check on
HikariConfig.setExceptionOverrideClassName
line 875should be changed, to attempt a load from the class loader obtained using
HikariConfig.class.getClassLoader()
for example, so at least the behaviour is consistent, and you would get aClassNotFoundException
when creating theHikariConfig