Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to set exceptionOverride instance, not just class name #2171

Open
hgschmie opened this issue Feb 13, 2024 · 1 comment
Open

ability to set exceptionOverride instance, not just class name #2171

hgschmie opened this issue Feb 13, 2024 · 1 comment

Comments

@hgschmie
Copy link

Hi,

We have an issue with spurious messages where the server gets shut down while some test code is still running. Our test cases work fine, but this creates messages like this:

WARN com.zaxxer.hikari.pool.ProxyConnection - jdbi-template-pool (*.*) - Connection oracle.jdbc.driver.T4CConnection@4886b6bd marked as broken because of SQLSTATE(08006), ErrorCode(18730)

I know it is broken, because we just shut down the server. To suppress those messages (QE keeps pestering us about "exceptions in test cases"), I am using a simple SQLExceptionOverride implementation that, in case we are in the process of shutting down, reject eviction (which suppresses that message).

However, because I can only pass in the class name into the config, I need to use a class level field to set that state. I'd like to use an instance level field (because I might use multiple connection pools). Right now, I am using this:

public static final class ExceptionOverrider implements SQLExceptionOverride {
        private static volatile boolean CLOSED = false;

        public Override adjudicate(SQLException sqlException) {
            return CLOSED ? Override.DO_NOT_EVICT : Override.CONTINUE_EVICT;
        }
    }

and call ExceptionOverrider.CLOSED = true to change state.

but I want to use this:

public static final class ExceptionOverrider implements SQLExceptionOverride {
        private volatile boolean closed = false;

        public Override adjudicate(SQLException sqlException) {
            return closed ? Override.DO_NOT_EVICT : Override.CONTINUE_EVICT;
        }
    }

which would allow me to use multiple, independent overrider instances.

However, I can neither pass my instance into the config (It only takes a string with the class name) nor can I retrieve the instantiated object from the pool base (It is package private and there is no setter).

Is it possible to make that instance accessible (make that field public final similar to the config)?

quaff added a commit to quaff/HikariCP that referenced this issue Feb 20, 2024
…loaded

Before this commit, exceptionOverrideClass may be loaded by different ClassLoader, and two instances are created but only the latter one is used. This commit make sure the class will only loaded once and only one instance is created.

Fix brettwooldridgeGH-2124
Fix brettwooldridgeGH-2171
@quaff
Copy link
Contributor

quaff commented Feb 20, 2024

It should be covered by #2133.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants