1616
1717package com .zaxxer .hikari .pool ;
1818
19- import static com .zaxxer .hikari .util .ClockSource .currentTime ;
19+ import com .zaxxer .hikari .util .FastList ;
20+ import org .slf4j .Logger ;
21+ import org .slf4j .LoggerFactory ;
2022
2123import java .lang .reflect .InvocationHandler ;
2224import java .lang .reflect .Proxy ;
23- import java .sql .CallableStatement ;
24- import java .sql .Connection ;
25- import java .sql .DatabaseMetaData ;
26- import java .sql .PreparedStatement ;
27- import java .sql .SQLException ;
28- import java .sql .Savepoint ;
29- import java .sql .Statement ;
30- import java .sql .Wrapper ;
25+ import java .sql .*;
3126import java .util .HashSet ;
3227import java .util .Set ;
3328import java .util .concurrent .Executor ;
3429
35- import org .slf4j .Logger ;
36- import org .slf4j .LoggerFactory ;
37-
38- import com .zaxxer .hikari .util .FastList ;
30+ import static com .zaxxer .hikari .util .ClockSource .currentTime ;
3931
4032/**
4133 * This is the proxy class for java.sql.Connection.
@@ -264,6 +256,7 @@ public final void close() throws SQLException
264256
265257 /** {@inheritDoc} */
266258 @ Override
259+ @ SuppressWarnings ("RedundantThrows" )
267260 public boolean isClosed () throws SQLException
268261 {
269262 return (delegate == ClosedConnection .CLOSED_CONNECTION );
@@ -447,7 +440,7 @@ public void setSchema(String schema) throws SQLException
447440 @ Override
448441 public final boolean isWrapperFor (Class <?> iface ) throws SQLException
449442 {
450- return iface .isInstance (delegate ) || (delegate instanceof Wrapper && delegate .isWrapperFor (iface ));
443+ return iface .isInstance (delegate ) || (delegate != null && delegate .isWrapperFor (iface ));
451444 }
452445
453446 /** {@inheritDoc} */
@@ -458,7 +451,7 @@ public final <T> T unwrap(Class<T> iface) throws SQLException
458451 if (iface .isInstance (delegate )) {
459452 return (T ) delegate ;
460453 }
461- else if (delegate instanceof Wrapper ) {
454+ else if (delegate != null ) {
462455 return delegate .unwrap (iface );
463456 }
464457
@@ -477,12 +470,18 @@ private static Connection getClosedConnection()
477470 {
478471 InvocationHandler handler = (proxy , method , args ) -> {
479472 final String methodName = method .getName ();
480- if ("abort " .equals (methodName )) {
481- return Void . TYPE ;
473+ if ("isClosed " .equals (methodName )) {
474+ return Boolean . TRUE ;
482475 }
483476 else if ("isValid" .equals (methodName )) {
484477 return Boolean .FALSE ;
485478 }
479+ if ("abort" .equals (methodName )) {
480+ return Void .TYPE ;
481+ }
482+ if ("close" .equals (methodName )) {
483+ return Void .TYPE ;
484+ }
486485 else if ("toString" .equals (methodName )) {
487486 return ClosedConnection .class .getCanonicalName ();
488487 }
0 commit comments