mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
fix cancel future directly
Signed-off-by: mmews <marcus.mews@numberfour.eu>
This commit is contained in:
parent
d620e0daae
commit
cefc79857a
2 changed files with 13 additions and 9 deletions
|
@ -17,6 +17,7 @@ import org.apache.log4j.Logger
|
|||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
import org.eclipse.xtext.service.OperationCanceledManager
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import java.util.concurrent.CancellationException
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -58,12 +59,13 @@ class RequestManager {
|
|||
protected def <V> CompletableFuture<V> submit(AbstractRequest<V> request) {
|
||||
requests += request
|
||||
queue.submit(request)
|
||||
val result = request.get.whenComplete[v, throwable|
|
||||
if (throwable !== null && !isCancelException(throwable)) {
|
||||
LOG.error("Error during request: ", throwable);
|
||||
val future = request.get;
|
||||
future.whenComplete[v, thr|
|
||||
if (thr !== null && !isCancelException(thr) && !(thr instanceof CancellationException)) {
|
||||
LOG.error("Error during request: ", thr);
|
||||
}
|
||||
]
|
||||
return result
|
||||
return future
|
||||
}
|
||||
|
||||
protected def CompletableFuture<Void> cancel() {
|
||||
|
|
|
@ -10,6 +10,7 @@ package org.eclipse.xtext.ide.server.concurrent;
|
|||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -66,13 +67,14 @@ public class RequestManager {
|
|||
protected <V extends Object> CompletableFuture<V> submit(final AbstractRequest<V> request) {
|
||||
this.requests.add(request);
|
||||
this.queue.submit(request);
|
||||
final BiConsumer<V, Throwable> _function = (V v, Throwable throwable) -> {
|
||||
if (((throwable != null) && (!this.isCancelException(throwable)))) {
|
||||
RequestManager.LOG.error("Error during request: ", throwable);
|
||||
final CompletableFuture<V> future = request.get();
|
||||
final BiConsumer<V, Throwable> _function = (V v, Throwable thr) -> {
|
||||
if ((((thr != null) && (!this.isCancelException(thr))) && (!(thr instanceof CancellationException)))) {
|
||||
RequestManager.LOG.error("Error during request: ", thr);
|
||||
}
|
||||
};
|
||||
final CompletableFuture<V> result = request.get().whenComplete(_function);
|
||||
return result;
|
||||
future.whenComplete(_function);
|
||||
return future;
|
||||
}
|
||||
|
||||
protected CompletableFuture<Void> cancel() {
|
||||
|
|
Loading…
Reference in a new issue