From 561d7bacafa2f42073e89a656f6f998252392392 Mon Sep 17 00:00:00 2001 From: abel Date: Mon, 13 Aug 2018 19:53:48 +0800 Subject: [PATCH] fix npe --- .../fr/third/alibaba/druid/pool/DruidDataSource.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java b/fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java index 567ccd5c8..1a7727687 100644 --- a/fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java +++ b/fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java @@ -613,6 +613,12 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat } private void checkThread() throws SQLException { + if (createConnectionThread == null){ + throw new IllegalStateException("createConnectionThread not start!"); + } + if (destroyConnectionThread == null){ + throw new IllegalStateException("destroyConnectionThread not start!"); + } if (!createConnectionThread.isStarted() && !destroyConnectionThread.isStarted()) { synchronized (this) {//线程安全问题,加个双检锁 if (!createConnectionThread.isStarted() && !destroyConnectionThread.isStarted()) { @@ -2152,8 +2158,8 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat try { Thread.sleep(timeBetweenConnectErrorMillis); - } catch (InterruptedException interruptEx) { - break; + } catch (InterruptedException ignore) { + } DruidDataSource.this.createThreadChange(); break;