This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 3d5eb467fc feat: Standardized null detection coding (#5345)
3d5eb467fc is described below
commit 3d5eb467fc4ac41290eb013bb6c745ce3fe8d96b
Author: 山山山山山 <[email protected]>
AuthorDate: Fri Dec 8 14:18:32 2023 +0800
feat: Standardized null detection coding (#5345)
Co-authored-by: 刘进山 <[email protected]>
Co-authored-by: xiaoyu <[email protected]>
---
.../shenyu/admin/service/impl/AlertDispatchServiceImpl.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertDispatchServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertDispatchServiceImpl.java
index 30b5fd1dd5..52faab64ec 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertDispatchServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertDispatchServiceImpl.java
@@ -29,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
@@ -126,7 +127,7 @@ public class AlertDispatchServiceImpl implements
AlertDispatchService, Disposabl
@Override
public void run() {
- if (alert != null) {
+ if (Objects.nonNull(alert)) {
sendNotify(alert);
}
}
@@ -154,13 +155,14 @@ public class AlertDispatchServiceImpl implements
AlertDispatchService, Disposabl
if (item.isMatchAll()) {
return true;
}
- if (item.getLevels() != null &&
!item.getLevels().isEmpty()) {
+
+ if (!CollectionUtils.isEmpty(item.getLevels())) {
boolean levelMatch =
item.getLevels().stream().anyMatch(level -> level == alert.getLevel());
if (!levelMatch) {
return false;
}
}
- if (item.getLabels() != null &&
!item.getLabels().isEmpty()) {
+ if (!CollectionUtils.isEmpty(item.getLabels())) {
return
item.getLabels().entrySet().stream().anyMatch(entry -> {
if (alert.getLabels() == null ||
!alert.getLabels().containsKey(entry.getKey())) {
return false;