Skip to content

Commit

Permalink
Remove redundant method
Browse files Browse the repository at this point in the history
  • Loading branch information
HindujaB committed Oct 12, 2024
1 parent e7bca86 commit 4f1120e
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.stdlib.email.util.EmailConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import static io.ballerina.stdlib.email.util.EmailConstants.ON_CLOSE;
import static io.ballerina.stdlib.email.util.EmailConstants.ON_ERROR;
import static io.ballerina.stdlib.email.util.EmailConstants.ON_MESSAGE;

/**
Expand Down Expand Up @@ -64,7 +65,7 @@ public boolean onMessage(EmailEvent emailEvent) {
if (runtime != null) {
Set<Map.Entry<String, BObject>> services = registeredServices.entrySet();
for (Map.Entry<String, BObject> service : services) {
invokeAsyncCall(service.getValue(), ON_MESSAGE, email);
runtime.call(service.getValue(), ON_MESSAGE, email);
}
} else {
log.error("Runtime should not be null.");
Expand All @@ -81,7 +82,7 @@ public void onError(Object error) {
if (runtime != null) {
Set<Map.Entry<String, BObject>> services = registeredServices.entrySet();
for (Map.Entry<String, BObject> service : services) {
invokeAsyncCall(service.getValue(), EmailConstants.ON_ERROR, error);
runtime.call(service.getValue(), ON_ERROR, error);
}
} else {
log.error("Runtime should not be null.");
Expand All @@ -99,7 +100,7 @@ public void onClose(Object error) {
if (runtime != null) {
Set<Map.Entry<String, BObject>> services = registeredServices.entrySet();
for (Map.Entry<String, BObject> service : services) {
invokeAsyncCall(service.getValue(), EmailConstants.ON_CLOSE, error);
runtime.call(service.getValue(), ON_CLOSE, error);
}
} else {
log.error("Runtime should not be null.");
Expand All @@ -115,8 +116,4 @@ protected void addService(BObject service) {
}
}

private void invokeAsyncCall(BObject service, String methodName, Object arg) {
runtime.call(service, methodName, arg);
}

}

0 comments on commit 4f1120e

Please sign in to comment.