Skip to content

Commit

Permalink
fix createSchedulerFuture
Browse files Browse the repository at this point in the history
  • Loading branch information
zrlw authored and wenshao committed Nov 26, 2023
1 parent 0f4a360 commit 4cd8403
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public class DruidDataSource extends DruidAbstractDataSource
private volatile ScheduledFuture<?> destroySchedulerFuture;
private DestroyTask destroyTask;

private volatile Future<?> createSchedulerFuture;

private final Map<CreateConnectionTask, Future<?>> createSchedulerFutures = new ConcurrentHashMap<>(16);
private CreateConnectionThread createConnectionThread;
private DestroyConnectionThread destroyConnectionThread;
private LogStatsThread logStatsThread;
Expand Down Expand Up @@ -1077,7 +1076,7 @@ private void submitCreateTask(boolean initTask) {
createTasks = array;
}

this.createSchedulerFuture = createScheduler.submit(task);
this.createSchedulerFutures.put(task, createScheduler.submit(task));
}

private boolean clearCreateTask(long taskId) {
Expand Down Expand Up @@ -2221,7 +2220,7 @@ public void close() {
destroyConnectionThread.interrupt();
}

if (createSchedulerFuture != null) {
for (Future<?> createSchedulerFuture : createSchedulerFutures.values()) {
createSchedulerFuture.cancel(true);
}

Expand Down Expand Up @@ -2809,7 +2808,8 @@ private void runInternal() {
return;
}

createSchedulerFuture = createScheduler.schedule(this, timeBetweenConnectErrorMillis, TimeUnit.MILLISECONDS);
createSchedulerFutures.put(this,
createScheduler.schedule(this, timeBetweenConnectErrorMillis, TimeUnit.MILLISECONDS));
return;
}
} catch (SQLException e) {
Expand Down Expand Up @@ -2849,7 +2849,8 @@ private void runInternal() {
return;
}

createSchedulerFuture = createScheduler.schedule(this, timeBetweenConnectErrorMillis, TimeUnit.MILLISECONDS);
createSchedulerFutures.put(this,
createScheduler.schedule(this, timeBetweenConnectErrorMillis, TimeUnit.MILLISECONDS));
return;
}
} catch (RuntimeException e) {
Expand Down

0 comments on commit 4cd8403

Please sign in to comment.