This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev-2.1.4
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev-2.1.4 by this push:
     new 50b9a256a [Improve] Objects.isNull improvements
50b9a256a is described below

commit 50b9a256a4863fa95e0982270a1f7fa841a22499
Author: benjobs <[email protected]>
AuthorDate: Thu Apr 4 21:34:47 2024 +0800

    [Improve] Objects.isNull improvements
---
 .../org/apache/streampark/common/util/ReflectUtils.scala    |  4 ++--
 .../console/base/exception/ApiAlertException.java           |  4 +---
 .../console/core/bean/SettingAlertEmailConfigParams.java    | 13 ++++++-------
 .../console/core/bean/SettingDockerConfigParams.java        |  9 ++++-----
 .../streampark/console/core/metrics/flink/CheckPoints.java  |  2 +-
 .../console/system/service/impl/AccessTokenServiceImpl.java |  5 ++---
 6 files changed, 16 insertions(+), 21 deletions(-)

diff --git 
a/streampark-common/src/main/scala/org/apache/streampark/common/util/ReflectUtils.scala
 
b/streampark-common/src/main/scala/org/apache/streampark/common/util/ReflectUtils.scala
index 092bf3449..15ea1910d 100644
--- 
a/streampark-common/src/main/scala/org/apache/streampark/common/util/ReflectUtils.scala
+++ 
b/streampark-common/src/main/scala/org/apache/streampark/common/util/ReflectUtils.scala
@@ -50,7 +50,7 @@ object ReflectUtils extends Logger {
   }
 
   def getFieldValue(obj: Any, field: Field): Any = {
-    if (Objects.isNull(obj) || Objects.isNull(field)) null
+    if (obj == null || field == null) null
     else {
       field.setAccessible(true)
       field.get(obj) match {
@@ -62,7 +62,7 @@ object ReflectUtils extends Logger {
 
   def setFieldValue(obj: Any, fieldName: String, value: Any): Unit = {
     val field = getAccessibleField(obj, fieldName)
-    if (Objects.isNull(field))
+    if (field == null)
       throw new IllegalArgumentException(
         "Could not find field [" + fieldName + "] on target [" + obj + "]")
     try
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/exception/ApiAlertException.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/exception/ApiAlertException.java
index 03b29452f..330300aa2 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/exception/ApiAlertException.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/exception/ApiAlertException.java
@@ -19,8 +19,6 @@ package org.apache.streampark.console.base.exception;
 
 import org.apache.streampark.console.base.domain.ResponseCode;
 
-import java.util.Objects;
-
 /**
  *
  *
@@ -47,7 +45,7 @@ public class ApiAlertException extends AbstractApiException {
   }
 
   public static void throwIfNull(Object object, String errorMessage) {
-    if (Objects.isNull(object)) {
+    if (object == null) {
       throw new ApiAlertException(errorMessage);
     }
   }
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingAlertEmailConfigParams.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingAlertEmailConfigParams.java
index b30e36b4f..4388305ed 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingAlertEmailConfigParams.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingAlertEmailConfigParams.java
@@ -22,7 +22,6 @@ import org.apache.streampark.console.core.entity.Setting;
 import lombok.Getter;
 import lombok.Setter;
 
-import java.util.Objects;
 import java.util.regex.Pattern;
 
 @Getter
@@ -58,42 +57,42 @@ public class SettingAlertEmailConfigParams {
   }
 
   private boolean verifyHost() {
-    if (Objects.isNull(getHost()) || 
Objects.isNull(getHost().getSettingValue())) {
+    if (getHost() == null || getHost().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(EMAIL_ADDRESS_REGEXP, getHost().getSettingValue());
   }
 
   private boolean verifyPort() {
-    if (Objects.isNull(getPort()) || 
Objects.isNull(getPort().getSettingValue())) {
+    if (getPort() == null || getPort().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(PORT_REGEXP, getPort().getSettingValue());
   }
 
   private boolean verifyFrom() {
-    if (Objects.isNull(getFrom()) || 
Objects.isNull(getFrom().getSettingValue())) {
+    if (getFrom() == null || getFrom().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(FROM_REGEXP, getFrom().getSettingValue());
   }
 
   private boolean verifyUserName() {
-    if (Objects.isNull(getUsername()) || 
Objects.isNull(getUsername().getSettingValue())) {
+    if (getUsername() == null || getUsername().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(USER_NAME_REGEXP, getUsername().getSettingValue());
   }
 
   private boolean verifyPassWord() {
-    if (Objects.isNull(getPassword()) || 
Objects.isNull(getPassword().getSettingValue())) {
+    if (getPassword() == null || getPassword().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(PASS_WORD_REGEXP, getPassword().getSettingValue());
   }
 
   private boolean verifySSL() {
-    if (Objects.isNull(getSsl()) || 
Objects.isNull(getSsl().getSettingValue())) {
+    if (getSsl() == null || getSsl().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(SSL_REGEXP, getSsl().getSettingValue());
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingDockerConfigParams.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingDockerConfigParams.java
index ba1250e8a..0b3fa1c3c 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingDockerConfigParams.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/bean/SettingDockerConfigParams.java
@@ -22,7 +22,6 @@ import org.apache.streampark.console.core.entity.Setting;
 import lombok.Getter;
 import lombok.Setter;
 
-import java.util.Objects;
 import java.util.regex.Pattern;
 
 @Getter
@@ -56,21 +55,21 @@ public class SettingDockerConfigParams {
   }
 
   private boolean verifyUserName() {
-    if (Objects.isNull(getUsername()) || 
Objects.isNull(getUsername().getSettingValue())) {
+    if (getUsername() == null || getUsername().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(USER_NAME_REGEXP, getUsername().getSettingValue());
   }
 
   private boolean verifyPassWord() {
-    if (Objects.isNull(getPassword()) || 
Objects.isNull(getPassword().getSettingValue())) {
+    if (getPassword() == null || getPassword().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(PASSWORD_REGEXP, getPassword().getSettingValue());
   }
 
   private boolean verifyAddress() {
-    if (Objects.isNull(getAddress()) || 
Objects.isNull(getAddress().getSettingValue())) {
+    if (getAddress() == null || getAddress().getSettingValue() == null) {
       return false;
     }
 
@@ -80,7 +79,7 @@ public class SettingDockerConfigParams {
   }
 
   private boolean verifyNameSpace() {
-    if (Objects.isNull(getNamespace()) || 
Objects.isNull(getNamespace().getSettingValue())) {
+    if (getNamespace() == null || getNamespace().getSettingValue() == null) {
       return false;
     }
     return Pattern.matches(NAMESPACE_REGEX, getNamespace().getSettingValue());
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/CheckPoints.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/CheckPoints.java
index f96ed5282..1cafc0b7f 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/CheckPoints.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/metrics/flink/CheckPoints.java
@@ -41,7 +41,7 @@ public class CheckPoints implements Serializable {
 
   @JsonIgnore
   public List<CheckPoint> getLatestCheckpoint() {
-    if (Objects.isNull(latest)) {
+    if (latest == null) {
       return Collections.emptyList();
     }
     return latest.getLatestCheckpoint();
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java
index d2526ce80..7b33def30 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java
@@ -42,7 +42,6 @@ import 
org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
-import java.util.Objects;
 
 @Slf4j
 @Service
@@ -55,7 +54,7 @@ public class AccessTokenServiceImpl extends 
ServiceImpl<AccessTokenMapper, Acces
   @Override
   public RestResponse create(Long userId, String description) {
     User user = userService.getById(userId);
-    if (Objects.isNull(user)) {
+    if (user == null) {
       return RestResponse.success().put("code", 0).message("user not 
available");
     }
     String token =
@@ -101,7 +100,7 @@ public class AccessTokenServiceImpl extends 
ServiceImpl<AccessTokenMapper, Acces
   @Override
   public RestResponse toggleToken(Long tokenId) {
     AccessToken tokenInfo = baseMapper.getById(tokenId);
-    if (Objects.isNull(tokenInfo)) {
+    if (tokenInfo == null) {
       return RestResponse.fail("accessToken could not be found!", 
ResponseCode.CODE_FAIL_ALERT);
     }
 

Reply via email to