Update reactor to 3.1.5 and fix an NPE caused by misused api

This commit is contained in:
Kris De Volder
2018-03-16 15:45:57 -07:00
parent 9473dfd75a
commit a28990512e
3 changed files with 15 additions and 9 deletions

View File

@@ -24,7 +24,8 @@ public class AsyncRunner {
private static Scheduler executor = Schedulers.newSingle("STS4 Thread");
// Only need to remember the last request as requests are executed in order, if
// Used in test harness to wait for all pending request to finish.
// We only need to remember the last request as requests are executed in order, so if
// the last request is done, all requests are done
private CompletableFuture<?> lastRequest;
@@ -51,10 +52,15 @@ public class AsyncRunner {
}
public synchronized CompletableFuture<Void> execute(RunnableWithException runnable) {
CompletableFuture<Void> x = Mono.fromCallable(() -> {
runnable.run();
return (Void)null;
}).subscribeOn(executor).toFuture();
CompletableFuture<Void> x = Mono.<Void>fromRunnable(() -> {
try {
runnable.run();
} catch (Exception e) {
throw new RuntimeException(e);
}
})
.subscribeOn(executor)
.toFuture();
lastRequest = x;
return x;
}

View File

@@ -188,12 +188,12 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
(String)params.getArguments().get(0), params.getArguments().get(1)
);
return quickfixResolve(quickfixParams)
.then((QuickfixEdit edit) -> {
.flatMap((QuickfixEdit edit) -> {
Mono<ApplyWorkspaceEditResponse> applyEdit = Mono.fromFuture(client.applyEdit(new ApplyWorkspaceEditParams(edit.workspaceEdit)));
Mono<Object> moveCursor = edit.cursorMovement==null
? Mono.just(new ApplyWorkspaceEditResponse(true))
: Mono.fromFuture(client.moveCursor(edit.cursorMovement));
return applyEdit.then(r -> r.getApplied() ? moveCursor : Mono.just(new ApplyWorkspaceEditResponse(true)));
return applyEdit.flatMap(r -> r.getApplied() ? moveCursor : Mono.just(new ApplyWorkspaceEditResponse(true)));
})
.toFuture();
}
@@ -568,7 +568,7 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
// }
engine.reconcile(doc, problems);
})
.otherwise(error -> {
.onErrorResume(error -> {
Log.log(error);
return Mono.empty();
})

View File

@@ -81,7 +81,7 @@
<jersey-2-version>2.10</jersey-2-version>
<lsp4j-version>0.4.0-SNAPSHOT</lsp4j-version>
<!-- NOTE: Reactor version must match version used by the CF client -->
<reactor-version>3.0.5.RELEASE</reactor-version>
<reactor-version>3.1.5.RELEASE</reactor-version>
<reactor-netty>0.6.0.RELEASE</reactor-netty>
<cloudfoundry-client-version>2.4.0.RELEASE</cloudfoundry-client-version>
<commons-io-version>2.4</commons-io-version>