Skip to content

Commit

Permalink
Make restart requests synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
NipunaRanasinghe committed Jan 9, 2025
1 parent a7c5338 commit bc12a96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,23 +449,21 @@ public CompletableFuture<Void> stepOut(StepOutArguments args) {

@Override
public CompletableFuture<Void> restart(RestartArguments args) {
return CompletableFuture.supplyAsync(() -> {
if (context.getDebugMode() == ExecutionContext.DebugMode.ATTACH) {
outputLogger.sendErrorOutput("Restart operation is not supported in remote debug mode.");
return null;
}
if (context.getDebugMode() == ExecutionContext.DebugMode.ATTACH) {
outputLogger.sendErrorOutput("Restart operation is not supported in remote debug mode.");
return CompletableFuture.completedFuture(null);
}

try {
resetServer();
launchDebuggeeProgram();
} catch (Exception e) {
LOGGER.error("Failed to restart the Ballerina program due to: {}", e.getMessage(), e);
outputLogger.sendErrorOutput("Failed to restart the Ballerina program");
terminateDebugSession(context.getDebuggeeVM() != null, true);
}
try {
resetServer();
launchDebuggeeProgram();
} catch (Exception e) {
LOGGER.error("Failed to restart the Ballerina program due to: {}", e.getMessage(), e);
outputLogger.sendErrorOutput("Failed to restart the Ballerina program");
terminateDebugSession(context.getDebuggeeVM() != null, true);
}

return null;
});
return CompletableFuture.completedFuture(null);
}

private void launchDebuggeeProgram() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private enum DefaultTimeouts {
SET_BREAKPOINTS(10000),
CONFIG_DONE(2000),
ATTACH(5000),
LAUNCH(15000),
LAUNCH(10000),
THREADS(2000),
STACK_TRACE(7000),
SCOPES(2000),
Expand All @@ -395,7 +395,7 @@ private enum DefaultTimeouts {
STEP_OUT(5000),
RESUME(5000),
PAUSE(5000),
RESTART(20000),
RESTART(10000),
DISCONNECT(5000);

private final long value;
Expand Down

0 comments on commit bc12a96

Please sign in to comment.