Skip to content

Commit

Permalink
Fix more test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
NipunaRanasinghe committed Dec 4, 2024
1 parent ce89d14 commit 55cee50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public class JBallerinaDebugServer implements IDebugProtocolServer {
private DebugExpressionEvaluator evaluator;
private ThreadReferenceProxyImpl activeThread;

private final AtomicInteger nextVarReference = new AtomicInteger();
private final AtomicInteger nextVarReference = new AtomicInteger(1);
private final Map<Integer, StackFrameProxyImpl> stackFrames = new HashMap<>();
private final Map<Long, StackFrame[]> threadStackTraces = new HashMap<>();
private final Map<Integer, Integer> scopeIdToFrameIds = new HashMap<>();
Expand Down Expand Up @@ -269,24 +269,24 @@ public CompletableFuture<Void> launch(Map<String, Object> args) {
launchDebuggeeProgram();
return CompletableFuture.completedFuture(null);
} catch (Exception e) {
outputLogger.sendErrorOutput("Failed to launch the ballerina program due to: " + e);
return CompletableFuture.completedFuture(null);
outputLogger.sendErrorOutput("Failed to launch the Ballerina program due to: " + e.getMessage());
return CompletableFuture.failedFuture(e);

Check warning on line 273 in misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java

View check run for this annotation

Codecov / codecov/patch

misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java#L272-L273

Added lines #L272 - L273 were not covered by tests
}
}

@Override
public CompletableFuture<Void> attach(Map<String, Object> args) {
try {
resetServer();
context.setDebugMode(ExecutionContext.DebugMode.ATTACH);
clientConfigHolder = new ClientAttachConfigHolder(args);
context.setDebugMode(ExecutionContext.DebugMode.ATTACH);

Check warning on line 281 in misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java

View check run for this annotation

Codecov / codecov/patch

misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java#L281

Added line #L281 was not covered by tests
Project sourceProject = context.getProjectCache().getProject(Path.of(clientConfigHolder.getSourcePath()));
context.setSourceProject(sourceProject);
ClientAttachConfigHolder configHolder = (ClientAttachConfigHolder) clientConfigHolder;

String hostName = configHolder.getHostName().orElse("");
int portName = configHolder.getDebuggePort();
attachToRemoteVM(hostName, portName);
return CompletableFuture.completedFuture(null);

Check warning on line 289 in misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java

View check run for this annotation

Codecov / codecov/patch

misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java#L289

Added line #L289 was not covered by tests
} catch (Exception e) {
String host = ((ClientAttachConfigHolder) clientConfigHolder).getHostName().orElse(LOCAL_HOST);
String portName;
Expand All @@ -296,11 +296,11 @@ public CompletableFuture<Void> attach(Map<String, Object> args) {
portName = VALUE_UNKNOWN;
}
LOGGER.error(e.getMessage());
outputLogger.sendErrorOutput(String.format("Failed to attach to the target VM, address: '%s:%s'.",
host, portName));
outputLogger.sendErrorOutput(String.format("Failed to attach to the target VM address: '%s:%s' due to: %s",
host, portName, e.getMessage()));

Check warning on line 300 in misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java

View check run for this annotation

Codecov / codecov/patch

misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java#L299-L300

Added lines #L299 - L300 were not covered by tests
terminateDebugSession(context.getDebuggeeVM() != null, false);
return CompletableFuture.failedFuture(e);

Check warning on line 302 in misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java

View check run for this annotation

Codecov / codecov/patch

misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JBallerinaDebugServer.java#L302

Added line #L302 was not covered by tests
}
return CompletableFuture.completedFuture(null);
}

@Override
Expand Down Expand Up @@ -1235,8 +1235,8 @@ private void clearSuspendedState() {
* Clears all state information.
*/
private void resetServer() {
eventProcessor.reset();
outputLogger.reset();
Optional.ofNullable(eventProcessor).ifPresent(JDIEventProcessor::reset);
Optional.ofNullable(outputLogger).ifPresent(DebugOutputLogger::reset);
terminateDebuggee();
clearSuspendedState();
context.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ void startListenAsync() {
processEvent(eventSet, eventIterator.next());
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
// Break the loop on serious errors
break;
LOGGER.error("Error occurred while processing JDI events.", e);

Check warning on line 99 in misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JDIEventProcessor.java

View check run for this annotation

Codecov / codecov/patch

misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/JDIEventProcessor.java#L99

Added line #L99 was not covered by tests
}
}

Expand Down

0 comments on commit 55cee50

Please sign in to comment.