mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-15 14:56:05 -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();
|
Exception t = task.getException();
|
||||||
if (t instanceof DownloadException)
|
if (t instanceof DownloadException)
|
||||||
throw new LibraryDownloadException(library, t.getCause());
|
throw new LibraryDownloadException(library, t.getCause());
|
||||||
else if (t == null)
|
else if (t instanceof CancellationException)
|
||||||
throw new CancellationException();
|
throw new CancellationException();
|
||||||
else
|
else
|
||||||
throw new LibraryDownloadException(library, t);
|
throw new LibraryDownloadException(library, t);
|
||||||
|
@ -105,8 +105,10 @@ public final class AsyncTaskExecutor extends TaskExecutor {
|
|||||||
.thenComposeAsync(unused -> {
|
.thenComposeAsync(unused -> {
|
||||||
totTask.addAndGet(tasks.size());
|
totTask.addAndGet(tasks.size());
|
||||||
|
|
||||||
if (isCancelled())
|
if (isCancelled()) {
|
||||||
|
for (Task<?> task : tasks) task.setException(new CancellationException());
|
||||||
return CompletableFuture.runAsync(this::checkCancellation);
|
return CompletableFuture.runAsync(this::checkCancellation);
|
||||||
|
}
|
||||||
|
|
||||||
return CompletableFuture.allOf(tasks.stream()
|
return CompletableFuture.allOf(tasks.stream()
|
||||||
.map(task -> CompletableFuture.completedFuture(null)
|
.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) {
|
private <T> CompletableFuture<T> executeCompletableFutureTask(Task<?> parentTask, CompletableFutureTask<T> task) {
|
||||||
checkCancellation();
|
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(null)
|
return CompletableFuture.completedFuture(null)
|
||||||
.thenComposeAsync(unused -> {
|
.thenComposeAsync(unused -> {
|
||||||
checkCancellation();
|
checkCancellation();
|
||||||
@ -202,8 +202,6 @@ public final class AsyncTaskExecutor extends TaskExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T> CompletableFuture<T> executeNormalTask(Task<?> parentTask, Task<T> task) {
|
private <T> CompletableFuture<T> executeNormalTask(Task<?> parentTask, Task<T> task) {
|
||||||
checkCancellation();
|
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(null)
|
return CompletableFuture.completedFuture(null)
|
||||||
.thenComposeAsync(unused -> {
|
.thenComposeAsync(unused -> {
|
||||||
checkCancellation();
|
checkCancellation();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user