ballerina-lang
ballerina-lang copied to clipboard
[Bug]: 'gracefulStop()' method being called for the listeners which are not started
Description
$title
Steps to Reproduce
import ballerina/io;
listener DEF ep1 = new DEF("DEF");
listener ABC ep2 = new ABC("ABC");
public function main() returns error? {
io:println("main called");
// panic error("error from main");
}
function init() {
io:println("initializing current module");
}
public class ABC {
private string name = "";
public function init(string name){
self.name = name;
}
public function 'start() returns error? {
io:println("listener start called - " + self.name);
if (self.name == "ABC") {
error sampleErr = error("panicked while starting listener attached with " + self.name);
panic sampleErr;
}
}
public function gracefulStop() returns error? {
io:println("listener gracefulStop called - " + self.name);
return ();
}
public function immediateStop() returns error? {
io:println("listener immediateStop called - " + self.name);
return ();
}
public function attach(service object {} s, string[]|string? name = ()) returns error? {
io:println("listener attach called - " + self.name);
}
public function detach(service object {} s) returns error? {
io:println("listener detach called - " + self.name);
}
}
public class DEF {
private string name = "";
public function init(string name){
self.name = name;
}
public function 'start() returns error? {
io:println("listener start called - " + self.name);
if (self.name == "DEF") {
error sampleErr = error("panicked while starting listener attached with " + self.name);
panic sampleErr;
}
}
public function gracefulStop() returns error? {
io:println("listener gracefulStop called - " + self.name);
return ();
}
public function immediateStop() returns error? {
io:println("listener immediateStop called - " + self.name);
return ();
}
public function attach(service object {} s, string[]|string? name = ()) returns error? {
io:println("listener attach called - " + self.name);
}
public function detach(service object {} s) returns error? {
io:println("listener detach called - " + self.name);
}
}
Output:
initializing current module
main called
listener start called - DEF
error: panicked while starting listener attached with DEF
at DEF:start(Foo.bal:328)
listener gracefulStop called - DEF
listener gracefulStop called - ABC
Here the gracefulStop()
method of listener bound with ABC
has been called even without the 'start
method of it get called.
Affected Version(s)
2201.8.x
OS, DB, other environment details and versions
No response
Related area
-> Runtime
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response