Class ProxyExceptionHandler

java.lang.Object
io.higson.runtime.profiler.jdbc.proxy.ProxyExceptionHandler

public abstract class ProxyExceptionHandler extends Object
This is a helper exception handler to be used by all classes related to DataSourceProxy: - ConnectionProxy - StatementProxy - PreparedStatementProxy

Each of the above classes is defined as a java dynamic proxy (java.lang.reflect.Proxy) and uses its own InvocationHandler to handle proxy logic and then invoke delegate method. However, if delegate method throws an exception, the InvocationHandler receives that exception wrapped in InvocationTargetException which is a checked exception.

Now, the JDK dynamic proxy spec says that: If a checked exception is thrown by this method [...] then an UndeclaredThrowableException [...] will be thrown by the method invocation on the proxy instance. This would not be a correct behaviour of proxy, as proxy needs to be fully transparent. That's why the proxy logic must catch InvoctionTargetException and unwrap it using this helper class.

See Also:
  • Constructor Details

    • ProxyExceptionHandler

      public ProxyExceptionHandler()