Skip to content

Commit

Permalink
fix: revert changes made for resolving start-stop issue (#9915)
Browse files Browse the repository at this point in the history
  • Loading branch information
taefi committed Jan 29, 2021
1 parent 9a896db commit fced0b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -153,28 +152,14 @@ private DevModeHandler(Lookup lookup, int runningPort, File npmFolder,
reuseDevServer = config.reuseDevServer();
devServerPortFile = getDevServerPortFile(npmFolder);

/*
* Check whether executor is provided by the caller (framework). It
* doesn't matter which Executor to use: any is fine. The main reason to
* use managed executor is to stop the execution when the framework
* stops.
*/
Executor service = lookup.lookupAll(Executor.class).stream().findFirst()
.orElse(null);

BiConsumer<Void, ? super Throwable> action = (value, exception) -> {
// this will throw an exception if an exception has been thrown by
// the waitFor task
waitFor.getNow(null);
runOnFutureComplete(config);
};

if (service == null) {
devServerStartFuture = waitFor.whenCompleteAsync(action);
} else {
// if there is an executor use it to run the task
devServerStartFuture = waitFor.whenCompleteAsync(action, service);
}
devServerStartFuture = waitFor.whenCompleteAsync(action);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -388,25 +387,10 @@ public static void initDevModeHandler(Set<Class<?>> classes,
.withEmbeddableWebComponents(true).enablePnpm(enablePnpm)
.withHomeNodeExecRequired(useHomeNodeExec).build();

/*
* Check whether executor is provided by the caller (framework). It
* doesn't matter which Executor to use: any is fine. The main reason to
* use managed executor is to stop the execution when the framework
* stops.
*/
Executor service = lookup.lookupAll(Executor.class).stream().findFirst()
.orElse(null);

Runnable runnable = () -> runNodeTasks(context, tokenFileData,
tasks);

CompletableFuture<Void> nodeTasksFuture;
if (service == null) {
nodeTasksFuture = CompletableFuture.runAsync(runnable);
} else {
// if there is an executor use it to run the task
nodeTasksFuture = CompletableFuture.runAsync(runnable, service);
}
Runnable runnable = () -> runNodeTasks(context, tokenFileData, tasks);

CompletableFuture<Void> nodeTasksFuture = CompletableFuture
.runAsync(runnable);

DevModeHandler.start(
Lookup.compose(lookup,
Expand Down

0 comments on commit fced0b9

Please sign in to comment.