mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-14 22:37:06 -04:00
fix: cancellation exception.
This commit is contained in:
parent
de9233fba5
commit
cc8dd77d90
@ -98,7 +98,7 @@ public class LibraryDownloadTask extends Task<Void> {
|
||||
Exception t = task.getException();
|
||||
if (t instanceof DownloadException)
|
||||
throw new LibraryDownloadException(library, t.getCause());
|
||||
else if (t == null)
|
||||
else if (t instanceof CancellationException)
|
||||
throw new CancellationException();
|
||||
else
|
||||
throw new LibraryDownloadException(library, t);
|
||||
|
@ -105,8 +105,10 @@ public final class AsyncTaskExecutor extends TaskExecutor {
|
||||
.thenComposeAsync(unused -> {
|
||||
totTask.addAndGet(tasks.size());
|
||||
|
||||
if (isCancelled())
|
||||
if (isCancelled()) {
|
||||
for (Task<?> task : tasks) task.setException(new CancellationException());
|
||||
return CompletableFuture.runAsync(this::checkCancellation);
|
||||
}
|
||||
|
||||
return CompletableFuture.allOf(tasks.stream()
|
||||
.map(task -> CompletableFuture.completedFuture(null)
|
||||
@ -130,8 +132,6 @@ public final class AsyncTaskExecutor extends TaskExecutor {
|
||||
}
|
||||
|
||||
private <T> CompletableFuture<T> executeCompletableFutureTask(Task<?> parentTask, CompletableFutureTask<T> task) {
|
||||
checkCancellation();
|
||||
|
||||
return CompletableFuture.completedFuture(null)
|
||||
.thenComposeAsync(unused -> {
|
||||
checkCancellation();
|
||||
@ -202,8 +202,6 @@ public final class AsyncTaskExecutor extends TaskExecutor {
|
||||
}
|
||||
|
||||
private <T> CompletableFuture<T> executeNormalTask(Task<?> parentTask, Task<T> task) {
|
||||
checkCancellation();
|
||||
|
||||
return CompletableFuture.completedFuture(null)
|
||||
.thenComposeAsync(unused -> {
|
||||
checkCancellation();
|
||||
|
Loading…
x
Reference in New Issue
Block a user