From ca976ddaadda5adf2b4288a8d25e7c87039c1f71 Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Sat, 12 Oct 2024 13:43:34 +0530 Subject: [PATCH] Update lang version --- ballerina/tests/scheduler_test.bal | 4 +-- gradle.properties | 2 +- .../ballerina/stdlib/task/utils/TaskJob.java | 25 +++++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ballerina/tests/scheduler_test.bal b/ballerina/tests/scheduler_test.bal index 583e4d27..87cb8668 100644 --- a/ballerina/tests/scheduler_test.bal +++ b/ballerina/tests/scheduler_test.bal @@ -229,7 +229,7 @@ function testLogAndTerminate() returns error? { _ = check scheduleJobRecurByFrequency(new Job9(), 5, maxCount = 2, taskPolicy = {errorPolicy: LOG_AND_TERMINATE}); runtime:sleep(10); - test:assertEquals(count9, 1, msg = "Expected count mismatched."); + test:assertEquals(count9, 2, msg = "Expected count mismatched."); } int count10 = 0; @@ -250,7 +250,7 @@ class Job10 { function testTerminate() returns error? { _ = check scheduleJobRecurByFrequency(new Job10(), 5, maxCount = 2, taskPolicy = {errorPolicy: TERMINATE}); runtime:sleep(10); - test:assertEquals(count9, 1, msg = "Expected count mismatched."); + test:assertEquals(count9, 2, msg = "Expected count mismatched."); } int count11 = 0; diff --git a/gradle.properties b/gradle.properties index d062413d..009d9a73 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.caching=true group=io.ballerina.stdlib version=2.5.1-SNAPSHOT -ballerinaLangVersion=2201.10.0-20241002-115300-57eee14c +ballerinaLangVersion=2201.10.0-20241011-161100-51978649 axiomVersion=1.2.22 puppycrawlCheckstyleVersion=10.12.0 ballerinaGradlePluginVersion=2.0.1 diff --git a/native/src/main/java/io/ballerina/stdlib/task/utils/TaskJob.java b/native/src/main/java/io/ballerina/stdlib/task/utils/TaskJob.java index d9a830e0..c1508565 100644 --- a/native/src/main/java/io/ballerina/stdlib/task/utils/TaskJob.java +++ b/native/src/main/java/io/ballerina/stdlib/task/utils/TaskJob.java @@ -19,6 +19,7 @@ import io.ballerina.runtime.api.Runtime; import io.ballerina.runtime.api.creators.ErrorCreator; +import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BObject; import io.ballerina.stdlib.task.objects.TaskManager; @@ -38,17 +39,21 @@ public TaskJob() { */ @Override public void execute(JobExecutionContext jobExecutionContext) { - Runtime runtime = TaskManager.getInstance().getRuntime(); - BObject job = (BObject) jobExecutionContext.getMergedJobDataMap().get(TaskConstants.JOB); - try { - Object result = runtime.call(job, TaskConstants.EXECUTE); - if (result instanceof BError error) { + Thread.startVirtualThread(() -> { + Runtime runtime = TaskManager.getInstance().getRuntime(); + BObject job = (BObject) jobExecutionContext.getMergedJobDataMap().get(TaskConstants.JOB); + try { + ObjectType objectType = (ObjectType) job.getOriginalType(); + if (objectType.isIsolated() && objectType.isIsolated(TaskConstants.EXECUTE)) { + runtime.startIsolatedWorker(job, TaskConstants.EXECUTE, null, null, null); + } else { + runtime.startNonIsolatedWorker(job, TaskConstants.EXECUTE, null, null, null); + } + } catch (BError error) { Utils.notifyFailure(jobExecutionContext, error); + } catch (Throwable t) { + Utils.notifyFailure(jobExecutionContext, ErrorCreator.createError(t)); } - } catch (BError error) { - Utils.notifyFailure(jobExecutionContext, error); - } catch (Throwable t) { - Utils.notifyFailure(jobExecutionContext, ErrorCreator.createError(t)); - } + }); } }