github-advanced-security[bot] commented on code in PR #15163:
URL:
https://github.com/apache/dolphinscheduler/pull/15163#discussion_r1395355411
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java:
##########
@@ -352,4 +361,40 @@
return first.isPresent();
}
+ @Override
+ public Result<Object> testSend(int pluginDefineId, String
pluginInstanceParams) {
+ Result<Object> result = new Result<>();
+ Optional<Host> alertServerAddressOptional =
registryClient.getAlertServerAddress();
+ if (!alertServerAddressOptional.isPresent()) {
+ log.error("Cannot get alert server address, please check the alert
server is running");
+ putMsg(result, Status.ALERT_CHANNEL_NOT_EXIST);
+ return result;
+ }
+
+ Host alertServerAddress = alertServerAddressOptional.get();
+ AlertTestSendRequest alertTestSendRequest = new AlertTestSendRequest(
+ pluginDefineId,
+ pluginInstanceParams);
+
+ AlertSendResponse.AlertSendResponseResult alertSendResponse;
+
+ try {
+ IAlertOperator alertOperator =
SingletonJdkDynamicRpcClientProxyFactory
+ .getProxyClient(alertServerAddress.getAddress(),
IAlertOperator.class);
+ alertSendResponse =
alertOperator.sendTestAlert(alertTestSendRequest);
+ log.info("Send alert to: {} successfully, response: {}",
alertServerAddress, alertSendResponse);
+ } catch (Exception e) {
+ log.error("Send alert: {} to: {} failed", alertTestSendRequest,
alertServerAddress, e);
+ putMsg(result, Status.ALERT_CHANNEL_NOT_EXIST);
+ return result;
+ }
+
+ if (alertSendResponse != null && alertSendResponse.isSuccess()) {
+ putMsg(result, Status.SUCCESS);
+ } else {
+ putMsg(result, Status.ALERT_TEST_SENDING_FAILED,
alertSendResponse.getMessage());
Review Comment:
## Dereferenced variable may be null
Variable [alertSendResponse](1) may be null at this access as suggested by
[this](2) null guard.
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/3552)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]