diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 0015ee2d..35d69305 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -112,7 +112,7 @@ modules = [ [[package]] org = "ballerina" name = "observe" -version = "1.2.0" +version = "1.2.3" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] diff --git a/ballerina/listener_endpoint.bal b/ballerina/listener_endpoint.bal index 8ce722b3..589cece5 100644 --- a/ballerina/listener_endpoint.bal +++ b/ballerina/listener_endpoint.bal @@ -14,12 +14,12 @@ // specific language governing permissions and limitations // under the License. +import ballerina/jballerina.java; import ballerina/log; import ballerina/task; -import ballerina/jballerina.java; # Represents a service listener that monitors the FTP location. -public class Listener { +public isolated class Listener { private handle EMPTY_JAVA_STRING = java:fromString(""); private ListenerConfiguration config = {}; @@ -30,8 +30,10 @@ public class Listener { # + listenerConfig - Configurations for FTP listener # + return - `()` or else an `ftp:Error` upon failure to initialize the listener public isolated function init(ListenerConfiguration listenerConfig) returns Error? { - self.config = listenerConfig; - return initListener(self, self.config); + self.config = listenerConfig.clone(); + lock { + return initListener(self, self.config); + } } # Starts the `ftp:Listener`. @@ -91,13 +93,17 @@ public class Listener { } isolated function internalStart() returns error? { - self.jobId = check task:scheduleJobRecurByFrequency(new Job(self), self.config.pollingInterval); + lock { + self.jobId = check task:scheduleJobRecurByFrequency(new Job(self), self.config.pollingInterval); + } } isolated function stop() returns error? { - var id = self.jobId; - if id is task:JobId { - check task:unscheduleJob(id); + lock { + var id = self.jobId; + if id is task:JobId { + check task:unscheduleJob(id); + } } } diff --git a/changelog.md b/changelog.md index ffe0aff6..1c8b1fcd 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,12 @@ This file contains all the notable changes done to the Ballerina Email package t The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- [Isolated the `ftp:Listener`](https://github.com/ballerina-platform/module-ballerina-ftp/pull/1287) + ## [2.10.1] - 2024-07-24 ## Added