Browse Source

Merge pull request #95 in CORE/base-third from ~JU/base-third:feature/10.0 to feature/10.0

* commit 'd9aaa7ee1c62e0ab36e6011125898cf665f64caa':
  64位
  hash
  i386
  Lz4
  修改一下命名
  修改一下命名
  在所有生产线程退出的地方,都重新创建新的生产线程
  fix npe
research/11.0
ju 6 years ago
parent
commit
fc5f116c4e
  1. 2
      build.third_step6.gradle
  2. 16
      fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java

2
build.third_step6.gradle

@ -100,8 +100,8 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){
with dataContent.call("${srcDir}/fine-jedis/resources")
with dataContent.call("${srcDir}/fine-cssparser/src")
with dataContent.call("${srcDir}/fine-kryo/src")
with dataContent.call("${srcDir}/fine-lz4/resources")
with dataContent.call("${srcDir}/fine-lz4/src")
with dataContent.call("${srcDir}/fine-lz4/resources")
into "${classesDir}"
}
}

16
fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java

@ -602,7 +602,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
this.connectProperties = properties;
}
private synchronized void createThreadChange() {
private synchronized void doSomethingBeforeCreationThreadBreak() {
String threadName = "Druid-ConnectionPool-Create-" + System.identityHashCode(this) + this.getUrl();
createConnectionThread = new CreateConnectionThread(threadName);
createConnectionThread.setStarted(false);
@ -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()) {
@ -2119,6 +2125,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
} catch (InterruptedException e) {
lastCreateError = e;
lastErrorTimeMillis = System.currentTimeMillis();
DruidDataSource.this.doSomethingBeforeCreationThreadBreak();
break;
} finally {
lock.unlock();
@ -2152,10 +2159,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
try {
Thread.sleep(timeBetweenConnectErrorMillis);
} catch (InterruptedException interruptEx) {
break;
} catch (InterruptedException ignore) {
}
DruidDataSource.this.createThreadChange();
DruidDataSource.this.doSomethingBeforeCreationThreadBreak();
break;
}
} catch (RuntimeException e) {
@ -2165,6 +2172,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
} catch (Error e) {
LOG.error("create connection error", e);
setFailContinuous(true);
DruidDataSource.this.doSomethingBeforeCreationThreadBreak();
break;
}

Loading…
Cancel
Save