diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java index 52372ab0e2b6..2ec4586d1860 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java @@ -40,10 +40,10 @@ public class AsyncUtils { public static Object handleNonIsolatedStrand(Strand strand, Supplier resultSupplier) { + // This check required for non strand Threads. boolean runnable = strand.isRunnable(); if (runnable) { strand.yield(); - } Object result = resultSupplier.get(); if (runnable) { diff --git a/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/profiler/ProfilerTest.java b/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/profiler/ProfilerTest.java index b75810e7b066..a4f7a40658a0 100644 --- a/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/profiler/ProfilerTest.java +++ b/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/profiler/ProfilerTest.java @@ -137,8 +137,11 @@ public void testProfilerExecutionWithKillSignal() throws BallerinaTestException bMainInstance.waitForLeechers(List.of(beforeExecleechers), 20000); addLogLeechers(afterExecleechers, serverInfoLogReader); Thread.sleep(5000); - long processId = process.pid(); - Runtime.getRuntime().exec("kill -SIGINT " + processId); + ProcessHandle profilerHandle = process.children().findFirst().get().children().findFirst().get(); + long profileId = profilerHandle.pid(); + long balProcessID = profilerHandle.children().findFirst().get().pid(); + Runtime.getRuntime().exec("kill -SIGINT " + balProcessID); + Runtime.getRuntime().exec("kill -SIGINT " + profileId); bMainInstance.waitForLeechers(List.of(afterExecleechers), 20000); process.waitFor(); } catch (InterruptedException | IOException e) {