From 68d7b03766ad704b702709a374a83c7e61bb85e9 Mon Sep 17 00:00:00 2001 From: Kalaiyarasi Date: Thu, 25 Mar 2021 13:18:58 +0530 Subject: [PATCH] Add dependsOn in some test config --- task-ballerina/tests/schedulerTest.bal | 6 ++++-- .../stdlib/task/actions/TaskActions.java | 4 ---- .../stdlib/task/objects/TaskManager.java | 16 +++++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/task-ballerina/tests/schedulerTest.bal b/task-ballerina/tests/schedulerTest.bal index ab4d0ef5..4a39c49f 100644 --- a/task-ballerina/tests/schedulerTest.bal +++ b/task-ballerina/tests/schedulerTest.bal @@ -147,7 +147,8 @@ class Job6 { } @test:Config { - groups: ["FrequencyJob"] + groups: ["FrequencyJob"], + dependsOn: [testLogIgnore] } function testIgnoreTrigger() returns error? { JobId id = check scheduleJobRecurByFrequency(new Job6(), 5, maxCount = 10, taskPolicy = { waitingPolicy: IGNORE }); @@ -555,7 +556,8 @@ isolated function testMaxCountValidation() { } @test:Config { - groups: ["FrequencyJob"] + groups: ["FrequencyJob"], + dependsOn: [testLogIgnore] } isolated function testEmptyRunningJobs() returns error? { JobId[] ids = getRunningJobs(); diff --git a/task-native/src/main/java/org/ballerinalang/stdlib/task/actions/TaskActions.java b/task-native/src/main/java/org/ballerinalang/stdlib/task/actions/TaskActions.java index 9ecea799..591f5ed0 100644 --- a/task-native/src/main/java/org/ballerinalang/stdlib/task/actions/TaskActions.java +++ b/task-native/src/main/java/org/ballerinalang/stdlib/task/actions/TaskActions.java @@ -28,13 +28,10 @@ import org.ballerinalang.stdlib.task.exceptions.SchedulingException; import org.ballerinalang.stdlib.task.objects.TaskManager; import org.ballerinalang.stdlib.task.utils.TaskConstants; -import org.ballerinalang.stdlib.task.utils.TaskListener; import org.ballerinalang.stdlib.task.utils.Utils; import org.quartz.JobDataMap; import org.quartz.Scheduler; import org.quartz.SchedulerException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.math.BigDecimal; import java.util.Random; @@ -51,7 +48,6 @@ public class TaskActions { private static int bound = 1000000; private static String value = "1000"; - private static final Logger LOG = LoggerFactory.getLogger(TaskListener.class); public static Object configureThread(Environment env, long workerCount, long waitingTimeInMillis) { try { diff --git a/task-native/src/main/java/org/ballerinalang/stdlib/task/objects/TaskManager.java b/task-native/src/main/java/org/ballerinalang/stdlib/task/objects/TaskManager.java index edfe4cb1..e3c3c8f7 100644 --- a/task-native/src/main/java/org/ballerinalang/stdlib/task/objects/TaskManager.java +++ b/task-native/src/main/java/org/ballerinalang/stdlib/task/objects/TaskManager.java @@ -59,6 +59,9 @@ public static TaskManager getInstance() { public void initializeScheduler(Properties properties, Environment env) throws SchedulingException, SchedulerException { getAllRunningJobs(); + if (this.scheduler != null) { + this.scheduler.shutdown(); + } if (!triggerInfoMap.isEmpty()) { configureScheduler(properties, env); } else { @@ -79,11 +82,13 @@ public Scheduler getScheduler(Properties properties, Environment env) throws Sch if (isConfiguredSchFactory) { this.scheduler = Utils.initializeScheduler(this.properties); isConfiguredSchFactory = false; + setRuntime(env.getRuntime()); + } else { + if (this.scheduler == null || this.scheduler.isShutdown()) { + this.scheduler = Utils.initializeScheduler(properties); + setRuntime(env.getRuntime()); + } } - if (this.scheduler == null || this.scheduler.isShutdown()) { - this.scheduler = Utils.initializeScheduler(properties); - } - setRuntime(env.getRuntime()); return this.scheduler; } @@ -164,9 +169,6 @@ private boolean isTriggerCompleted(Trigger.TriggerState triggerState) { private void configureScheduler(Properties properties, Environment env) throws SchedulerException, SchedulingException { - if (this.scheduler != null) { - this.scheduler.shutdown(); - } this.scheduler = Utils.initializeScheduler(properties); setRuntime(env.getRuntime()); if (!triggerInfoMap.isEmpty()) {