Skip to content

Commit cb28de6

Browse files
authored
Merge pull request #16617 from iterate-ch/bugfix/MD-22686
No graceful shutdown of timer threads on disconnect.
2 parents 593ca7f + 62cd223 commit cb28de6

File tree

16 files changed

+27
-21
lines changed

16 files changed

+27
-21
lines changed

brick/src/main/java/ch/cyberduck/core/brick/BrickFileMigrationFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void uncaughtException(final Thread t, final Throwable e) {
100100
}
101101
}
102102
finally {
103-
scheduler.shutdown();
103+
scheduler.shutdown(true);
104104
}
105105
}
106106

brick/src/main/java/ch/cyberduck/core/brick/BrickPairingSchedulerFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,6 @@ public JsonObject handleEntity(final HttpEntity entity) throws IOException {
170170
}
171171

172172
public void shutdown() {
173-
scheduler.shutdown();
173+
scheduler.shutdown(true);
174174
}
175175
}

core/src/main/java/ch/cyberduck/core/features/Scheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ public interface Scheduler<R> {
3434
/**
3535
* Shutdown thread pool
3636
*/
37-
void shutdown();
37+
void shutdown(boolean gracefully);
3838
}

core/src/main/java/ch/cyberduck/core/shared/DelegatingSchedulerFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public Future<Void> execute(final PasswordCallback callback) {
4545
}
4646

4747
@Override
48-
public void shutdown() {
48+
public void shutdown(final boolean gracefully) {
4949
for(Scheduler scheduler : features) {
50-
scheduler.shutdown();
50+
scheduler.shutdown(gracefully);
5151
}
5252
}
5353
}

core/src/main/java/ch/cyberduck/core/shared/ThreadPoolSchedulerFeature.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public Future<R> execute(final PasswordCallback callback) {
5050
protected abstract R operate(PasswordCallback callback) throws BackgroundException;
5151

5252
@Override
53-
public void shutdown() {
53+
public void shutdown(final boolean gracefully) {
5454
log.debug("Shutting down scheduler thread pool {}", this);
55-
scheduler.shutdown();
55+
scheduler.shutdown(gracefully);
5656
}
5757

5858
private final class FailureAwareRunnable implements Runnable {
@@ -72,7 +72,7 @@ public void run() {
7272
}
7373
catch(Exception e) {
7474
log.error("Failure processing scheduled task {}", e.getMessage(), e);
75-
ThreadPoolSchedulerFeature.this.shutdown();
75+
ThreadPoolSchedulerFeature.this.shutdown(false);
7676
}
7777
}
7878
}

core/src/main/java/ch/cyberduck/core/threading/ScheduledThreadPool.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,15 @@ public ScheduledFuture<?> schedule(final Runnable runnable, final Long delay, fi
9696
return pool.schedule(runnable, delay, unit);
9797
}
9898

99-
public void shutdown() {
100-
log.info("Shutdown pool {}", pool);
101-
pool.shutdown();
99+
public void shutdown(final boolean gracefully) {
100+
if(gracefully) {
101+
log.info("Shutdown pool {} gracefully", pool);
102+
pool.shutdown();
103+
}
104+
else {
105+
log.info("Shutdown pool {} now", pool);
106+
pool.shutdownNow();
107+
}
102108
try {
103109
while(!pool.awaitTermination(1L, TimeUnit.SECONDS)) {
104110
log.warn("Await termination for pool {}", pool);

core/src/main/java/ch/cyberduck/core/threading/TransferBackgroundAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void finish() {
180180
progressTimer.cancel(false);
181181
transfer.stop();
182182
listener.transferDidStop(transfer);
183-
timerPool.shutdown();
183+
timerPool.shutdown(true);
184184
}
185185

186186
@Override

deepbox/src/main/java/ch/cyberduck/core/deepbox/DeepboxReadFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void uncaughtException(final Thread t, final Throwable e) {
130130
}
131131
}
132132
finally {
133-
scheduler.shutdown();
133+
scheduler.shutdown(true);
134134
}
135135
}
136136

dracoon/src/main/java/ch/cyberduck/core/sds/SDSSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public int hashCode() {
587587

588588
@Override
589589
protected void logout() {
590-
scheduler.shutdown();
590+
scheduler.shutdown(false);
591591
client.getHttpClient().close();
592592
nodeid.clear();
593593
}

dracoon/src/main/java/ch/cyberduck/core/sds/SDSUploadService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public void uncaughtException(final Thread t, final Throwable e) {
276276
throw new DefaultExceptionMappingService().map(Throwables.getRootCause(e));
277277
}
278278
}
279-
polling.shutdown();
279+
polling.shutdown(true);
280280
log.debug("Polling completed for {} with {} polls in {}ms ", file, polls.get(), System.currentTimeMillis() - start);
281281
if(null != failure.get()) {
282282
throw failure.get();

0 commit comments

Comments
 (0)