diff --git a/src/main/java/com/alibaba/druid/pool/DruidPooledConnection.java b/src/main/java/com/alibaba/druid/pool/DruidPooledConnection.java index 90677c7eb7..e743dced52 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidPooledConnection.java +++ b/src/main/java/com/alibaba/druid/pool/DruidPooledConnection.java @@ -1085,8 +1085,14 @@ public class DruidPooledConnection extends PoolableWrapper implements javax.sql. } public void checkState() throws SQLException { - boolean asyncCloseEnable = this.getConnectionHolder().getDataSource().isAsyncCloseConnectionEnable(); - if (asyncCloseEnable) { + final boolean asyncCloseEnabled; + if (holder != null) { + asyncCloseEnabled = holder.getDataSource().isAsyncCloseConnectionEnable(); + } else { + asyncCloseEnabled = false; + } + + if (asyncCloseEnabled) { synchronized (this) { checkStateInternal(); }