Compare commits

...

2 commits

Author SHA1 Message Date
Gravita
55d2fbd57f [ANY] Update modules 2023-03-23 20:28:03 +07:00
Gravita
111d7616d0 [FIX] NPE 2023-03-23 18:56:23 +07:00
2 changed files with 7 additions and 6 deletions

View file

@ -130,11 +130,12 @@ protected DownloadTask sendAsync(AsyncDownloader.SizedFile file, URI baseUri, Pa
ProgressTrackingBodyHandler<Path> bodyHandler = makeBodyHandler(targetDir.resolve(file.filePath), callback); ProgressTrackingBodyHandler<Path> bodyHandler = makeBodyHandler(targetDir.resolve(file.filePath), callback);
CompletableFuture<HttpResponse<Path>> future = client.sendAsync(makeHttpRequest(baseUri, file.urlPath), bodyHandler); CompletableFuture<HttpResponse<Path>> future = client.sendAsync(makeHttpRequest(baseUri, file.urlPath), bodyHandler);
AtomicReference<DownloadTask> task = new AtomicReference<>(null); AtomicReference<DownloadTask> task = new AtomicReference<>(null);
task.set(new DownloadTask(bodyHandler, future.thenApply((e) -> { task.set(new DownloadTask(bodyHandler, null /* fix NPE (future already completed) */));
tasks.add(task.get());
task.get().completableFuture = future.thenApply((e) -> {
tasks.remove(task.get()); tasks.remove(task.get());
return e; return e;
}))); });
tasks.add(task.get());
return task.get(); return task.get();
} }
@ -168,7 +169,7 @@ private static class ConsumerObject {
public static class DownloadTask { public static class DownloadTask {
public final ProgressTrackingBodyHandler<Path> bodyHandler; public final ProgressTrackingBodyHandler<Path> bodyHandler;
public final CompletableFuture<HttpResponse<Path>> completableFuture; public CompletableFuture<HttpResponse<Path>> completableFuture;
public DownloadTask(ProgressTrackingBodyHandler<Path> bodyHandler, CompletableFuture<HttpResponse<Path>> completableFuture) { public DownloadTask(ProgressTrackingBodyHandler<Path> bodyHandler, CompletableFuture<HttpResponse<Path>> completableFuture) {
this.bodyHandler = bodyHandler; this.bodyHandler = bodyHandler;

@ -1 +1 @@
Subproject commit 828d2483509744aefde1b6082f5a56dc14b4e1e4 Subproject commit ed433be234a5d6b4336a6af48194add97b0f2874