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

kevinclair 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 1fb8301e4 [type:refactor] removed unnecessary singleton (#4230)
1fb8301e4 is described below

commit 1fb8301e4cc7e589def0021f44ada21619adab1e
Author: 愿凌飞 <[email protected]>
AuthorDate: Thu Dec 1 11:25:34 2022 +0800

    [type:refactor] removed unnecessary singleton (#4230)
---
 .../apache/shenyu/admin/model/entity/AppAuthDO.java    |  4 ++--
 .../shenyu/admin/service/impl/AppAuthServiceImpl.java  |  2 +-
 .../apache/shenyu/admin/mapper/AppAuthMapperTest.java  |  6 +++---
 .../shenyu/admin/service/AppAuthServiceTest.java       |  2 +-
 .../java/org/apache/shenyu/common/utils/SignUtils.java | 18 ++----------------
 .../org/apache/shenyu/common/utils/SignUtilsTest.java  |  4 ++--
 6 files changed, 11 insertions(+), 25 deletions(-)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java
index 40555870f..087757ddb 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java
@@ -239,8 +239,8 @@ public final class AppAuthDO extends BaseDO {
                     .userId(item.getUserId())
                     .phone(item.getPhone())
                     .extInfo(item.getExtInfo())
-                    .appKey(SignUtils.getInstance().generateKey())
-                    .appSecret(SignUtils.getInstance().generateKey())
+                    .appKey(SignUtils.generateKey())
+                    .appSecret(SignUtils.generateKey())
                     .open(item.getOpen())
                     .enabled(true)
                     .dateCreated(currentTime)
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java
index e632b708a..6d568ec3d 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java
@@ -262,7 +262,7 @@ public class AppAuthServiceImpl implements AppAuthService {
         AppAuthDO appAuthDO = AppAuthDO.create(appAuthDTO);
         DataEventTypeEnum eventType;
         if (StringUtils.isBlank(appAuthDTO.getId())) {
-            appAuthDO.setAppSecret(SignUtils.getInstance().generateKey());
+            appAuthDO.setAppSecret(SignUtils.generateKey());
             appAuthCount = appAuthMapper.insertSelective(appAuthDO);
             eventType = DataEventTypeEnum.CREATE;
         } else {
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java
index 32dd633b1..6b2ed4cc7 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java
@@ -113,7 +113,7 @@ public final class AppAuthMapperTest extends 
AbstractSpringIntegrationTest {
 
     @Test
     public void testUpdateAppSecretByAppKey() {
-        String appSecret = SignUtils.getInstance().generateKey();
+        String appSecret = SignUtils.generateKey();
         appAuthDO.setAppSecret(appSecret);
         int count = 
appAuthMapper.updateAppSecretByAppKey(appAuthDO.getAppKey(), appSecret);
         assertEquals(1, count);
@@ -138,8 +138,8 @@ public final class AppAuthMapperTest extends 
AbstractSpringIntegrationTest {
         Timestamp now = new Timestamp(System.currentTimeMillis());
         return AppAuthDO.builder()
                 .id(UUIDUtils.getInstance().generateShortUuid())
-                .appKey(SignUtils.getInstance().generateKey())
-                .appSecret(SignUtils.getInstance().generateKey())
+                .appKey(SignUtils.generateKey())
+                .appSecret(SignUtils.generateKey())
                 .extInfo("{\"extInfo\":\"json\"}")
                 .open(true)
                 .enabled(false)
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
index ca6d78dfb..45f266777 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
@@ -202,7 +202,7 @@ public final class AppAuthServiceTest {
 
     @Test
     public void testUpdateAppSecretByAppKey() {
-        String newAppSecret = SignUtils.getInstance().generateKey();
+        String newAppSecret = SignUtils.generateKey();
         appAuthDO.setAppSecret(newAppSecret);
         
given(this.appAuthMapper.updateAppSecretByAppKey(appAuthDO.getAppKey(), 
appAuthDO.getAppSecret())).willReturn(1);
         ShenyuAdminResult result = 
this.appAuthService.updateAppSecretByAppKey(appAuthDO.getAppKey(), 
appAuthDO.getAppSecret());
diff --git 
a/shenyu-common/src/main/java/org/apache/shenyu/common/utils/SignUtils.java 
b/shenyu-common/src/main/java/org/apache/shenyu/common/utils/SignUtils.java
index 04e15325d..98b9039dc 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/utils/SignUtils.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/utils/SignUtils.java
@@ -31,20 +31,6 @@ import org.apache.commons.codec.digest.DigestUtils;
  */
 public final class SignUtils {
 
-    private static final SignUtils SIGN_UTILS = new SignUtils();
-
-    private SignUtils() {
-    }
-
-    /**
-     * getInstance.
-     *
-     * @return {@linkplain SignUtils}
-     */
-    public static SignUtils getInstance() {
-        return SIGN_UTILS;
-    }
-
     /**
      * acquired sign.
      *
@@ -78,7 +64,7 @@ public final class SignUtils {
      * @param signKey sign key
      * @return boolean
      */
-    public boolean isValid(final String sign, final Map<String, String> 
jsonParams, final Map<String, String> queryParams, final String signKey) {
+    public static boolean isValid(final String sign, final Map<String, String> 
jsonParams, final Map<String, String> queryParams, final String signKey) {
         return Objects.equals(sign, generateSign(signKey, jsonParams, 
queryParams));
     }
 
@@ -87,7 +73,7 @@ public final class SignUtils {
      *
      * @return the string
      */
-    public String generateKey() {
+    public static String generateKey() {
         return UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
     }
 
diff --git 
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java 
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java
index e3dcee744..08fd3d644 100644
--- 
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java
+++ 
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/SignUtilsTest.java
@@ -51,12 +51,12 @@ public final class SignUtilsTest {
         Map<String, String> queryParams = new HashMap<>();
         jsonParams.put("a", "1");
         jsonParams.put("b", "2");
-        assertTrue(SignUtils.getInstance().isValid(sign, jsonParams, 
queryParams, "test"));
+        assertTrue(SignUtils.isValid(sign, jsonParams, queryParams, "test"));
     }
 
     @Test
     public void testGenerateKey() {
-        assertNotNull(SignUtils.getInstance().generateKey());
+        assertNotNull(SignUtils.generateKey());
     }
 
     @Test

Reply via email to