mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] NPE
This commit is contained in:
parent
fb2883d215
commit
111d7616d0
1 changed files with 6 additions and 5 deletions
|
@ -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.remove(task.get());
|
|
||||||
return e;
|
|
||||||
})));
|
|
||||||
tasks.add(task.get());
|
tasks.add(task.get());
|
||||||
|
task.get().completableFuture = future.thenApply((e) -> {
|
||||||
|
tasks.remove(task.get());
|
||||||
|
return e;
|
||||||
|
});
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue