From 45fc756045eb82b2afbb7d034e6f16bfbe4a0501 Mon Sep 17 00:00:00 2001
From: George Tziavas <g.tziavas@ac.upatras.gr>
Date: Mon, 31 Mar 2025 16:32:02 +0300
Subject: [PATCH] added synchronized to JobService methods

---
 .../java/org/etsi/osl/metrico/services/JobService.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/etsi/osl/metrico/services/JobService.java b/src/main/java/org/etsi/osl/metrico/services/JobService.java
index 17b96fc..635d5e0 100644
--- a/src/main/java/org/etsi/osl/metrico/services/JobService.java
+++ b/src/main/java/org/etsi/osl/metrico/services/JobService.java
@@ -43,7 +43,7 @@ public class JobService {
      * @throws IllegalArgumentException   if the job's start or end date is invalid
      * @throws RejectedExecutionException if the job could not be scheduled
      */
-    public Job startJob(Runnable task, Job job) {
+    public synchronized Job startJob(Runnable task, Job job) {
         logger.debug("Starting Job for MeasurementCollectionJob with ID {}.", job.getMeasurementCollectionJobRef());
         MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO();
 
@@ -89,7 +89,7 @@ public class JobService {
      *
      * @param job the job to be stopped
      */
-    public void stopJob(Job job) {
+    public synchronized void stopJob(Job job) {
 
         MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO();
 
@@ -128,7 +128,7 @@ public class JobService {
      *
      * @param measurementCollectionJobUuid the UUID of the Measurement Collection Job
      */
-    public void stopJob(String measurementCollectionJobUuid) {
+    public synchronized void stopJob(String measurementCollectionJobUuid) {
         Job job = runningJobs.get(measurementCollectionJobUuid);
         if (job != null) {
             stopJob(job);
@@ -142,7 +142,7 @@ public class JobService {
      *
      * <p>This method iterates over all jobs in the runningJobs map, stops each job, and then clears the map.</p>
      */
-    public void stopAllJobs() {
+    public synchronized void stopAllJobs() {
         for (Job job : runningJobs.values()) {
             stopJob(job);
         }
-- 
GitLab