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

hefengen 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 3082629d93 [fix:bug] Fix admin sync bug (#4941)
3082629d93 is described below

commit 3082629d933af612ad025352f6c8623dc1dd040a
Author: yunlongn <[email protected]>
AuthorDate: Wed Aug 2 13:52:00 2023 +0800

    [fix:bug] Fix admin sync bug (#4941)
    
    * [type:bug] fix admin sync bug.
    
    * [type:bug] fix admin sync bug.
    
    * [type:bug] fix admin sync bug.
    
    * [type:bug] fix admin sync bug.
    
    * [type:bug] fix admin sync bug.
    
    * [type:bug] fix admin sync bug.
    
    ---------
    
    Co-authored-by: dragon-zhang <[email protected]>
---
 .../converter/AbstractSelectorHandleConverter.java |  3 +-
 .../admin/service/impl/UpstreamCheckService.java   | 11 ++--
 .../ShenyuClientRegisterDivideServiceImpl.java     | 15 +----
 .../ShenyuClientRegisterDubboServiceImpl.java      | 15 +----
 .../ShenyuClientRegisterGrpcServiceImpl.java       | 15 +----
 ...ShenyuClientRegisterSpringCloudServiceImpl.java | 15 +----
 .../ShenyuClientRegisterTarsServiceImpl.java       | 15 +----
 .../ShenyuClientRegisterDivideServiceImplTest.java | 68 +++++----------------
 .../ShenyuClientRegisterDubboServiceImplTest.java  | 71 ++++++----------------
 .../ShenyuClientRegisterGrpcServiceImplTest.java   | 63 ++++---------------
 ...yuClientRegisterSpringCloudServiceImplTest.java | 52 ++++------------
 .../ShenyuClientRegisterTarsServiceImplTest.java   | 35 +----------
 .../common/dto/convert/selector/DubboUpstream.java |  4 +-
 13 files changed, 76 insertions(+), 306 deletions(-)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java
index a06d08e2c2..01c57c1cdd 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/converter/AbstractSelectorHandleConverter.java
@@ -25,6 +25,7 @@ import 
org.apache.shenyu.common.dto.convert.selector.CommonUpstream;
 import org.apache.shenyu.common.utils.GsonUtils;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -68,7 +69,7 @@ public abstract class AbstractSelectorHandleConverter 
implements SelectorHandleC
      */
     @Override
     public <T extends CommonUpstream> List<T> updateStatusAndFilter(final 
List<T> existList, final List<? extends CommonUpstream> aliveList) {
-        if (CollectionUtils.isEmpty(aliveList) || 
CollectionUtils.isEmpty(existList)) {
+        if (Objects.isNull(aliveList)) {
             return Lists.newArrayList();
         }
         long currentTimeMillis = System.currentTimeMillis();
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/UpstreamCheckService.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/UpstreamCheckService.java
index 56ed75e79e..c7e687bdf5 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/UpstreamCheckService.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/UpstreamCheckService.java
@@ -187,15 +187,14 @@ public class UpstreamCheckService {
     }
 
     /**
-     * Submit.
+     * Submit client health check.
      *
      * @param selectorId     the selector id
      * @param commonUpstream the common upstream
-     * @return whether this module handles
      */
-    public boolean submit(final String selectorId, final CommonUpstream 
commonUpstream) {
+    public void submit(final String selectorId, final CommonUpstream 
commonUpstream) {
         if (!REGISTER_TYPE_HTTP.equalsIgnoreCase(registerType) || !checked) {
-            return false;
+            return;
         }
 
         List<CommonUpstream> upstreams = 
MapUtils.computeIfAbsent(UPSTREAM_MAP, selectorId, k -> new 
CopyOnWriteArrayList<>());
@@ -213,7 +212,6 @@ public class UpstreamCheckService {
             PENDING_SYNC.add(NumberUtils.INTEGER_ZERO);
         }
         executor.execute(() -> updateHandler(selectorId, upstreams, 
upstreams));
-        return true;
     }
 
     /**
@@ -234,7 +232,8 @@ public class UpstreamCheckService {
     public boolean checkAndSubmit(final String selectorId, final 
CommonUpstream commonUpstream) {
         final boolean pass = 
UpstreamCheckUtils.checkUrl(commonUpstream.getUpstreamUrl());
         if (pass) {
-            return submit(selectorId, commonUpstream);
+            this.submit(selectorId, commonUpstream);
+            return false;
         }
         ZOMBIE_SET.add(ZombieUpstream.transform(commonUpstream, 
zombieCheckTimes, selectorId));
         LOG.error("add zombie node, url={}", commonUpstream.getUpstreamUrl());
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImpl.java
index 90a4a226bc..066c9bd491 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImpl.java
@@ -107,20 +107,7 @@ public class ShenyuClientRegisterDivideServiceImpl extends 
AbstractContextPathRe
         if (doSubmit(selectorDO.getId(), canAddList)) {
             return null;
         }
-
-        List<DivideUpstream> handleList;
-        if (CollectionUtils.isEmpty(existList)) {
-            handleList = addList;
-        } else {
-            List<DivideUpstream> aliveList;
-            if (isEventDeleted) {
-                aliveList = existList.stream().filter(e -> e.isStatus() && 
!e.equals(addList.get(0))).collect(Collectors.toList());
-            } else {
-                aliveList = addList;
-            }
-            handleList = 
divideSelectorHandleConverter.updateStatusAndFilter(existList, aliveList);
-        }
-        return GsonUtils.getInstance().toJson(handleList);
+        return 
GsonUtils.getInstance().toJson(CollectionUtils.isEmpty(existList) ? canAddList 
: existList);
     }
 
     private List<DivideUpstream> buildDivideUpstreamList(final 
List<URIRegisterDTO> uriList) {
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
index 7e1d373dc0..6553f83bd0 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImpl.java
@@ -95,20 +95,7 @@ public class ShenyuClientRegisterDubboServiceImpl extends 
AbstractShenyuClientRe
         if (doSubmit(selectorDO.getId(), canAddList)) {
             return null;
         }
-
-        List<DubboUpstream> handleList;
-        if (CollectionUtils.isEmpty(existList)) {
-            handleList = addList;
-        } else {
-            List<DubboUpstream> aliveList;
-            if (isEventDeleted) {
-                aliveList = existList.stream().filter(e -> e.isStatus() && 
!e.equals(addList.get(0))).collect(Collectors.toList());
-            } else {
-                aliveList = addList;
-            }
-            handleList = 
dubboSelectorHandleConverter.updateStatusAndFilter(existList, aliveList);
-        }
-        return GsonUtils.getInstance().toJson(handleList);
+        return 
GsonUtils.getInstance().toJson(CollectionUtils.isEmpty(existList) ? canAddList 
: existList);
     }
 
     private List<DubboUpstream> buildDubboUpstreamList(final 
List<URIRegisterDTO> uriList) {
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
index 0277568624..b6c45f3945 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImpl.java
@@ -101,20 +101,7 @@ public class ShenyuClientRegisterGrpcServiceImpl extends 
AbstractShenyuClientReg
         if (doSubmit(selectorDO.getId(), canAddList)) {
             return null;
         }
-
-        List<GrpcUpstream> handleList;
-        if (CollectionUtils.isEmpty(existList)) {
-            handleList = addList;
-        } else {
-            List<GrpcUpstream> aliveList;
-            if (isEventDeleted) {
-                aliveList = existList.stream().filter(e -> e.isStatus() && 
!e.equals(addList.get(0))).collect(Collectors.toList());
-            } else {
-                aliveList = addList;
-            }
-            handleList = 
grpcSelectorHandleConverter.updateStatusAndFilter(existList, aliveList);
-        }
-        return GsonUtils.getInstance().toJson(handleList);
+        return 
GsonUtils.getInstance().toJson(CollectionUtils.isEmpty(existList) ? canAddList 
: existList);
     }
 
     private List<GrpcUpstream> buildGrpcUpstreamList(final 
List<URIRegisterDTO> uriList) {
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImpl.java
index 6b4ff08804..c6a5801088 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImpl.java
@@ -98,20 +98,7 @@ public class ShenyuClientRegisterSpringCloudServiceImpl 
extends AbstractContextP
         if (doSubmit(selectorDO.getId(), canAddList)) {
             return null;
         }
-
-        List<DivideUpstream> handleList;
-        if (CollectionUtils.isEmpty(existList)) {
-            handleList = addList;
-        } else {
-            List<DivideUpstream> aliveList;
-            if (isEventDeleted) {
-                aliveList = existList.stream().filter(e -> e.isStatus() && 
!e.equals(addList.get(0))).collect(Collectors.toList());
-            } else {
-                aliveList = addList;
-            }
-            handleList = 
springCloudSelectorHandleConverter.updateStatusAndFilter(existList, aliveList);
-        }
-        springCloudSelectorHandle.setDivideUpstreams(handleList);
+        
springCloudSelectorHandle.setDivideUpstreams(CollectionUtils.isEmpty(existList) 
? canAddList : existList);
         return GsonUtils.getInstance().toJson(springCloudSelectorHandle);
     }
 
diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
index 0b69166631..7cb8d96138 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImpl.java
@@ -94,20 +94,7 @@ public class ShenyuClientRegisterTarsServiceImpl extends 
AbstractShenyuClientReg
         if (doSubmit(selectorDO.getId(), canAddList)) {
             return null;
         }
-
-        List<TarsUpstream> handleList;
-        if (CollectionUtils.isEmpty(existList)) {
-            handleList = addList;
-        } else {
-            List<TarsUpstream> aliveList;
-            if (isEventDeleted) {
-                aliveList = existList.stream().filter(e -> e.isStatus() && 
!e.equals(addList.get(0))).collect(Collectors.toList());
-            } else {
-                aliveList = addList;
-            }
-            handleList = 
tarsSelectorHandleConverter.updateStatusAndFilter(existList, aliveList);
-        }
-        return GsonUtils.getInstance().toJson(handleList);
+        return 
GsonUtils.getInstance().toJson(CollectionUtils.isEmpty(existList) ? canAddList 
: existList);
     }
 
     private List<TarsUpstream> buildTarsUpstreamList(final 
List<URIRegisterDTO> uriList) {
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImplTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImplTest.java
index af584699d0..558f41351e 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImplTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDivideServiceImplTest.java
@@ -22,16 +22,14 @@ import org.apache.shenyu.admin.model.entity.MetaDataDO;
 import org.apache.shenyu.admin.model.entity.SelectorDO;
 import org.apache.shenyu.admin.service.converter.DivideSelectorHandleConverter;
 import org.apache.shenyu.admin.service.impl.MetaDataServiceImpl;
-import org.apache.shenyu.admin.utils.CommonUpstreamUtils;
 import org.apache.shenyu.common.dto.convert.rule.impl.DivideRuleHandle;
-import org.apache.shenyu.common.dto.convert.selector.CommonUpstream;
 import org.apache.shenyu.common.dto.convert.selector.DivideUpstream;
+import org.apache.shenyu.common.dto.convert.selector.TarsUpstream;
 import org.apache.shenyu.common.enums.RpcTypeEnum;
 import org.apache.shenyu.common.exception.ShenyuException;
 import org.apache.shenyu.common.utils.GsonUtils;
 import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
 import org.apache.shenyu.register.common.dto.URIRegisterDTO;
-import org.apache.shenyu.register.common.enums.EventType;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -41,7 +39,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
 import org.springframework.test.util.ReflectionTestUtils;
-import com.google.gson.JsonParser;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -100,78 +97,43 @@ public final class 
ShenyuClientRegisterDivideServiceImplTest {
         shenyuClientRegisterDivideService.registerMetadata(metaDataDTO);
         verify(metaDataService).saveOrUpdateMetaData(metaDataDO, metaDataDTO);
     }
-    
+
     @Test
     public void testBuildHandle() {
         shenyuClientRegisterDivideService = 
spy(shenyuClientRegisterDivideService);
-        
-        final String returnStr = 
"[{protocol:'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8090',warmup:10,weight:50,status:false,timestamp:1637826588267},"
-                + 
"{protocol:'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8091',warmup:10,weight:50,status:true,timestamp:1637826588267},"
-                + 
"{protocol:'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8092',warmup:10,weight:50,status:false,timestamp:"
 + (System.currentTimeMillis() + 60000) + "}]";
+
+        final String returnStr = 
"[{protocol:'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8090',warmup:10,weight:50,status:true,timestamp:1637826588267},"
+                + 
"{protocol:'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8091',warmup:10,weight:50,status:true,timestamp:1637826588267}]";
         final String expected = 
"[{\"weight\":50,\"warmup\":10,\"protocol\":\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8090\",\"status\":true,\"timestamp\":1637826588267},";
-                + 
"{\"weight\":50,\"warmup\":10,\"protocol\":\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8091\",\"status\":true,\"timestamp\":1637826588267},";
-                + 
"{\"weight\":50,\"warmup\":10,\"protocol\":\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8092\",\"status\":false,\"timestamp\":1637826588267}]";;
+                + 
"{\"weight\":50,\"warmup\":10,\"protocol\":\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8091\",\"status\":true,\"timestamp\":1637826588267}]";;
         List<URIRegisterDTO> list = new ArrayList<>();
         
list.add(URIRegisterDTO.builder().protocol("http://";).appName("test1").rpcType(RpcTypeEnum.HTTP.getName()).host(LOCALHOST).port(8090).build());
-        
list.add(URIRegisterDTO.builder().protocol("http://";).appName("test1").rpcType(RpcTypeEnum.HTTP.getName()).host(LOCALHOST).port(8091).build());
         SelectorDO selectorDO = mock(SelectorDO.class);
         when(selectorDO.getHandle()).thenReturn(returnStr);
         
doReturn(false).when(shenyuClientRegisterDivideService).doSubmit(any(), any());
         String actual = shenyuClientRegisterDivideService.buildHandle(list, 
selectorDO);
-        assertEquals(JsonParser.parseString(expected.replaceAll("\\d{13}", 
"0")), JsonParser.parseString(actual.replaceAll("\\d{13}", "0")));
-        List<DivideUpstream> resultList = 
GsonUtils.getInstance().fromCurrentList(actual, DivideUpstream.class);
-        assertEquals(resultList.size(), 3);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
+        assertEquals(expected, actual);
+        List<TarsUpstream> resultList = 
GsonUtils.getInstance().fromCurrentList(actual, TarsUpstream.class);
+        assertEquals(resultList.size(), 2);
 
         list.clear();
-        
list.add(URIRegisterDTO.builder().protocol("http://";).appName("test1").rpcType(RpcTypeEnum.HTTP.getName()).host(LOCALHOST).port(8093).build());
+        
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.HTTP.getName()).host(LOCALHOST).port(8092).build());
         selectorDO = mock(SelectorDO.class);
         when(selectorDO.getHandle()).thenReturn(returnStr);
         
doReturn(false).when(shenyuClientRegisterDivideService).doSubmit(any(), any());
         actual = shenyuClientRegisterDivideService.buildHandle(list, 
selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DivideUpstream.class);
-        //localhost:8090 was removed because the stop time was too long
+        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
TarsUpstream.class);
         assertEquals(resultList.size(), 3);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
-
-        list.clear();
-        
list.add(URIRegisterDTO.builder().protocol("http://";).appName("test1").rpcType(RpcTypeEnum.HTTP.getName()).host(LOCALHOST).port(8091)/*.eventType(EventType.DELETED)*/.build());
-        
doReturn(false).when(shenyuClientRegisterDivideService).doSubmit(any(), any());
-        selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn(returnStr);
-        actual = shenyuClientRegisterDivideService.buildHandle(list, 
selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DivideUpstream.class);
-        assertEquals(resultList.size(), 2);
-        assertEquals(resultList.stream().anyMatch(r -> !r.isStatus() /*&& 
r.getUpstreamUrl().equals("localhost:8091")*/), true);
 
         list.clear();
-        
list.add(URIRegisterDTO.builder().protocol("http://";).appName("test1").rpcType(RpcTypeEnum.HTTP.getName()).host(LOCALHOST).port(8090).eventType(EventType.DELETED).build());
+        
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.HTTP.getName()).host(LOCALHOST).port(8090).build());
         
doReturn(false).when(shenyuClientRegisterDivideService).doSubmit(any(), any());
         selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn(returnStr);
-        actual = shenyuClientRegisterDivideService.buildHandle(list, 
selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DivideUpstream.class);
-        assertEquals(resultList.size(), 2);
-        assertEquals(resultList.stream().anyMatch(r -> r.isStatus() && 
r.getUpstreamUrl().equals("localhost:8091")), true);
-        assertEquals(resultList.stream().anyMatch(r -> !r.isStatus() && 
r.getUpstreamUrl().equals("localhost:8092")), true);
-
-        doReturn(true).when(shenyuClientRegisterDivideService).doSubmit(any(), 
any());
         actual = shenyuClientRegisterDivideService.buildHandle(list, 
selectorDO);
-        assertEquals(actual, null);
-
-        list.clear();
-        
doReturn(false).when(shenyuClientRegisterDivideService).doSubmit(any(), any());
-        actual = shenyuClientRegisterDivideService.buildHandle(list, 
selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DivideUpstream.class);
-        assertEquals(resultList.stream().allMatch(r -> !r.isStatus()), true);
+        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
TarsUpstream.class);
+        assertEquals(resultList.size(), 1);
     }
-    
+
     @Test
     public void testBuildDivideUpstreamList() {
         List<URIRegisterDTO> list = new ArrayList<>();
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImplTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImplTest.java
index 67aedcb508..2640311611 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImplTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterDubboServiceImplTest.java
@@ -20,11 +20,8 @@ package org.apache.shenyu.admin.service.register;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shenyu.admin.model.entity.MetaDataDO;
 import org.apache.shenyu.admin.model.entity.SelectorDO;
-import org.apache.shenyu.admin.service.converter.DubboSelectorHandleConverter;
 import org.apache.shenyu.admin.service.impl.MetaDataServiceImpl;
-import org.apache.shenyu.admin.utils.CommonUpstreamUtils;
 import org.apache.shenyu.common.dto.convert.rule.impl.DubboRuleHandle;
-import org.apache.shenyu.common.dto.convert.selector.CommonUpstream;
 import org.apache.shenyu.common.dto.convert.selector.DivideUpstream;
 import org.apache.shenyu.common.dto.convert.selector.DubboUpstream;
 import org.apache.shenyu.common.enums.RpcTypeEnum;
@@ -32,7 +29,6 @@ import org.apache.shenyu.common.exception.ShenyuException;
 import org.apache.shenyu.common.utils.GsonUtils;
 import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
 import org.apache.shenyu.register.common.dto.URIRegisterDTO;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.InjectMocks;
@@ -40,8 +36,6 @@ import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
-import org.springframework.test.util.ReflectionTestUtils;
-import com.google.gson.JsonParser;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -70,12 +64,6 @@ public final class ShenyuClientRegisterDubboServiceImplTest {
     @Mock
     private MetaDataServiceImpl metaDataService;
 
-    @BeforeEach
-    public void setUp() {
-        DubboSelectorHandleConverter dubboSelectorHandleConverter = new 
DubboSelectorHandleConverter();
-        ReflectionTestUtils.setField(shenyuClientRegisterDubboService, 
"dubboSelectorHandleConverter", dubboSelectorHandleConverter);
-    }
-
     @Test
     public void testRpcType() {
         assertEquals(RpcTypeEnum.DUBBO.getName(), 
shenyuClientRegisterDubboService.rpcType());
@@ -100,68 +88,49 @@ public final class 
ShenyuClientRegisterDubboServiceImplTest {
         shenyuClientRegisterDubboService.registerMetadata(metaDataDTO);
         verify(metaDataService).saveOrUpdateMetaData(metaDataDO, metaDataDTO);
     }
-    
+
     @Test
     public void testBuildHandle() {
         shenyuClientRegisterDubboService = 
spy(shenyuClientRegisterDubboService);
-    
-        final String returnStr = 
"[{protocol:'dubbo://',upstreamHost:'localhost',upstreamUrl:'localhost:8090',warmup:600000,weight:50,status:true,timestamp:1637826588267},"
-                + 
"{protocol:'dubbo://',upstreamHost:'localhost',upstreamUrl:'localhost:8091',warmup:600000,weight:50,status:false,timestamp:"
 + (System.currentTimeMillis() + 60000) + "}]";
-        final String expected = 
"[{\"port\":0,\"weight\":50,\"warmup\":600000,\"protocol\":\"dubbo://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8090\","
-                + 
"\"status\":true,\"timestamp\":1637826588267},{\"port\":0,\"weight\":50,\"warmup\":600000,\"protocol\":\"dubbo://\",\"upstreamHost\":\"localhost\","
-                + 
"\"upstreamUrl\":\"localhost:8091\",\"status\":false,\"timestamp\":1637826588267}]";
-        
+
+        final String returnStr = 
"[{protocol:'dubbo://',upstreamHost:'localhost',upstreamUrl:'localhost:8090',warmup:10,weight:50,status:true,timestamp:1637826588267},"
+                + 
"{protocol:'dubbo://',upstreamHost:'localhost',upstreamUrl:'localhost:8091',warmup:10,weight:50,status:true,timestamp:1637826588267}]";
+        final String expected = 
"[{\"port\":0,\"weight\":50,\"warmup\":10,\"protocol\":\"dubbo://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8090\","
+                + 
"\"status\":true,\"timestamp\":1637826588267},{\"port\":0,\"weight\":50,\"warmup\":10,\"protocol\":\"dubbo://\",\"upstreamHost\":\"localhost\","
+                + 
"\"upstreamUrl\":\"localhost:8091\",\"status\":true,\"timestamp\":1637826588267}]";
+
         List<URIRegisterDTO> list = new ArrayList<>();
-        
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.DUBBO.getName()).host(LOCALHOST).port(8090).build());
+        list.add(URIRegisterDTO.builder().appName("test1")
+                .rpcType(RpcTypeEnum.DUBBO.getName())
+                .host(LOCALHOST).port(8090).build());
         SelectorDO selectorDO = mock(SelectorDO.class);
         when(selectorDO.getHandle()).thenReturn(returnStr);
         doReturn(false).when(shenyuClientRegisterDubboService).doSubmit(any(), 
any());
         String actual = shenyuClientRegisterDubboService.buildHandle(list, 
selectorDO);
-        assertEquals(JsonParser.parseString(expected.replaceAll("\\d{13}", 
"0")), JsonParser.parseString(actual.replaceAll("\\d{13}", "0")));
+        assertEquals(expected, actual);
         List<DubboUpstream> resultList = 
GsonUtils.getInstance().fromCurrentList(actual, DubboUpstream.class);
         assertEquals(resultList.size(), 2);
 
-        //list.clear();
-        
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.DUBBO.getName()).host(LOCALHOST).port(8092).build());
+        list.clear();
+        list.add(URIRegisterDTO.builder().appName("test1")
+                .rpcType(RpcTypeEnum.DUBBO.getName())
+                .host(LOCALHOST).port(8092).build());
         selectorDO = mock(SelectorDO.class);
         when(selectorDO.getHandle()).thenReturn(returnStr);
         doReturn(false).when(shenyuClientRegisterDubboService).doSubmit(any(), 
any());
         actual = shenyuClientRegisterDubboService.buildHandle(list, 
selectorDO);
         resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DubboUpstream.class);
         assertEquals(resultList.size(), 3);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
 
         list.clear();
-        
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.DUBBO.getName()).host(LOCALHOST).port(8091).build());
-        doReturn(false).when(shenyuClientRegisterDubboService).doSubmit(any(), 
any());
-        selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn(returnStr);
-        actual = shenyuClientRegisterDubboService.buildHandle(list, 
selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DubboUpstream.class);
-        assertEquals(resultList.size(), 2);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
-
-        list.clear();
-        
list.add(URIRegisterDTO.builder().protocol("http://";).appName("test1").rpcType(RpcTypeEnum.DUBBO.getName()).host(LOCALHOST).port(8090)/*.eventType(EventType.DELETED)*/.build());
+        list.add(URIRegisterDTO.builder().appName("test1")
+                .rpcType(RpcTypeEnum.DUBBO.getName())
+                .host(LOCALHOST).port(8090).build());
         doReturn(false).when(shenyuClientRegisterDubboService).doSubmit(any(), 
any());
         selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn(returnStr);
-        actual = shenyuClientRegisterDubboService.buildHandle(list, 
selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DubboUpstream.class);
-        assertEquals(resultList.size(), 2);
-        assertEquals(resultList.stream().anyMatch(r -> !r.isStatus()), true);
-
-        list.clear();
-        doReturn(false).when(shenyuClientRegisterDubboService).doSubmit(any(), 
any());
         actual = shenyuClientRegisterDubboService.buildHandle(list, 
selectorDO);
         resultList = GsonUtils.getInstance().fromCurrentList(actual, 
DubboUpstream.class);
-        assertEquals(resultList.stream().allMatch(r -> !r.isStatus()), true);
+        assertEquals(resultList.size(), 1);
     }
 
     @Test
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImplTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImplTest.java
index 8767bb4cad..4de58f2f33 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImplTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterGrpcServiceImplTest.java
@@ -16,23 +16,17 @@
  */
     
 package org.apache.shenyu.admin.service.register;
-    
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shenyu.admin.model.entity.MetaDataDO;
 import org.apache.shenyu.admin.model.entity.SelectorDO;
-import org.apache.shenyu.admin.service.converter.GrpcSelectorHandleConverter;
 import org.apache.shenyu.admin.service.impl.MetaDataServiceImpl;
-import org.apache.shenyu.admin.utils.CommonUpstreamUtils;
-import org.apache.shenyu.common.dto.convert.selector.CommonUpstream;
-import org.apache.shenyu.common.dto.convert.selector.GrpcUpstream;
 import org.apache.shenyu.common.dto.convert.selector.TarsUpstream;
 import org.apache.shenyu.common.enums.RpcTypeEnum;
 import org.apache.shenyu.common.exception.ShenyuException;
 import org.apache.shenyu.common.utils.GsonUtils;
 import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
 import org.apache.shenyu.register.common.dto.URIRegisterDTO;
-import org.apache.shenyu.register.common.enums.EventType;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.InjectMocks;
@@ -40,8 +34,6 @@ import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
-import org.springframework.test.util.ReflectionTestUtils;
-import com.google.gson.JsonParser;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -68,12 +60,6 @@ public final class ShenyuClientRegisterGrpcServiceImplTest {
     @Mock
     private MetaDataServiceImpl metaDataService;
 
-    @BeforeEach
-    public void setUp() {
-        GrpcSelectorHandleConverter grpcSelectorHandleConverter = new 
GrpcSelectorHandleConverter();
-        ReflectionTestUtils.setField(shenyuClientRegisterGrpcService, 
"grpcSelectorHandleConverter", grpcSelectorHandleConverter);
-    }
-
     @Test
     public void testRpcType() {
         assertEquals(RpcTypeEnum.GRPC.getName(), 
shenyuClientRegisterGrpcService.rpcType());
@@ -99,66 +85,43 @@ public final class ShenyuClientRegisterGrpcServiceImplTest {
         verify(metaDataService).findByPath("/test");
         verify(metaDataService).saveOrUpdateMetaData(metaDataDO, metaDataDTO);
     }
-    
+
     @Test
     public void testBuildHandle() {
         shenyuClientRegisterGrpcService = spy(shenyuClientRegisterGrpcService);
-        
+
         final String returnStr = 
"[{upstreamUrl='localhost:8090',weight=1,status=true,timestamp=1637826588267},"
                 + 
"{upstreamUrl='localhost:8091',weight=2,status=true,timestamp=1637826588267}]";
         final String expected = 
"[{\"weight\":1,\"upstreamUrl\":\"localhost:8090\",\"status\":true,\"timestamp\":1637826588267},"
                 + 
"{\"weight\":2,\"upstreamUrl\":\"localhost:8091\",\"status\":true,\"timestamp\":1637826588267}]";
-    
+
         List<URIRegisterDTO> list = new ArrayList<>();
         
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.GRPC.getName()).host("localhost").port(8090).build());
-        
list.add(URIRegisterDTO.builder().appName("test2").rpcType(RpcTypeEnum.GRPC.getName()).host("localhost").port(8091).build());
         SelectorDO selectorDO = mock(SelectorDO.class);
         when(selectorDO.getHandle()).thenReturn(returnStr);
         doReturn(false).when(shenyuClientRegisterGrpcService).doSubmit(any(), 
any());
         String actual = shenyuClientRegisterGrpcService.buildHandle(list, 
selectorDO);
-        assertEquals(JsonParser.parseString(expected), 
JsonParser.parseString(actual));
-        List<GrpcUpstream> resultList = 
GsonUtils.getInstance().fromCurrentList(actual, GrpcUpstream.class);
+
+        assertEquals(actual, expected);
+        List<TarsUpstream> resultList = 
GsonUtils.getInstance().fromCurrentList(actual, TarsUpstream.class);
         assertEquals(resultList.size(), 2);
-    
-        //list.clear();
+
+        list.clear();
         
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.GRPC.getName()).host("localhost").port(8092).build());
         selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn("");
+        when(selectorDO.getHandle()).thenReturn(returnStr);
         doReturn(false).when(shenyuClientRegisterGrpcService).doSubmit(any(), 
any());
         actual = shenyuClientRegisterGrpcService.buildHandle(list, selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
GrpcUpstream.class);
+        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
TarsUpstream.class);
         assertEquals(resultList.size(), 3);
-        assertEquals(resultList.stream().anyMatch(CommonUpstream::isStatus), 
true);
 
         list.clear();
         
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.GRPC.getName()).host("localhost").port(8090).build());
         doReturn(false).when(shenyuClientRegisterGrpcService).doSubmit(any(), 
any());
         selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn(returnStr);
-        actual = shenyuClientRegisterGrpcService.buildHandle(list, selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
GrpcUpstream.class);
-        assertEquals(resultList.size(), 2);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
-
-        list.clear();
-        
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.GRPC.getName()).host("localhost").port(8090).eventType(EventType.DELETED).build());
-        doReturn(false).when(shenyuClientRegisterGrpcService).doSubmit(any(), 
any());
-        selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn(returnStr);
-        actual = shenyuClientRegisterGrpcService.buildHandle(list, selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
GrpcUpstream.class);
-        assertEquals(resultList.size(), 2);
-        assertEquals(resultList.stream().anyMatch(r -> !r.isStatus() && 
r.getUpstreamUrl().equals("localhost:8090")), true);
-        assertEquals(resultList.stream().anyMatch(r -> r.isStatus() && 
!r.getUpstreamUrl().equals("localhost:8090")), true);
-
-        list.clear();
-        doReturn(false).when(shenyuClientRegisterGrpcService).doSubmit(any(), 
any());
         actual = shenyuClientRegisterGrpcService.buildHandle(list, selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
GrpcUpstream.class);
-        assertEquals(resultList.stream().allMatch(r -> !r.isStatus()), true);
+        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
TarsUpstream.class);
+        assertEquals(resultList.size(), 1);
     }
     
     @Test
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImplTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImplTest.java
index 768545d43f..7a32bb23df 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImplTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterSpringCloudServiceImplTest.java
@@ -21,15 +21,12 @@ import org.apache.shenyu.admin.model.entity.MetaDataDO;
 import org.apache.shenyu.admin.model.entity.SelectorDO;
 import 
org.apache.shenyu.admin.service.converter.SpringCloudSelectorHandleConverter;
 import org.apache.shenyu.admin.service.impl.MetaDataServiceImpl;
-import org.apache.shenyu.admin.utils.CommonUpstreamUtils;
 import org.apache.shenyu.common.dto.convert.rule.impl.SpringCloudRuleHandle;
-import org.apache.shenyu.common.dto.convert.selector.CommonUpstream;
 import org.apache.shenyu.common.dto.convert.selector.SpringCloudSelectorHandle;
 import org.apache.shenyu.common.enums.RpcTypeEnum;
 import org.apache.shenyu.common.utils.GsonUtils;
 import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
 import org.apache.shenyu.register.common.dto.URIRegisterDTO;
-import org.apache.shenyu.register.common.enums.EventType;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -39,7 +36,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
 import org.springframework.test.util.ReflectionTestUtils;
-import com.google.gson.JsonParser;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -104,14 +100,16 @@ public final class 
ShenyuClientRegisterSpringCloudServiceImplTest {
     public void testBuildHandle() {
         shenyuClientRegisterSpringCloudService = 
spy(shenyuClientRegisterSpringCloudService);
         
-        final String returnStr = 
"{serviceId:'test1',gray:false,divideUpstreams:["
-                + 
"{weight:50,warmup:10,protocol:'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8090',status:'true',timestamp:1637909490935},"
-                + 
"{weight:50,warmup:10,protocol:'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8091',status:'true',timestamp:1637909490935}]}";
-        final String expected = 
"{\"serviceId\":\"test1\",\"gray\":false,\"divideUpstreams\":["
-                + 
"{\"weight\":50,\"warmup\":10,\"protocol\":\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8090\",\"status\":true,\"timestamp\":1637909490935},";
-                + 
"{\"weight\":50,\"warmup\":10,\"protocol\":\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8091\",\"status\":false,\"timestamp\":1637909490935}]}";;
-        final URIRegisterDTO dto1 = 
URIRegisterDTO.builder().appName("test2").rpcType(RpcTypeEnum.SPRING_CLOUD.getName()).host(HOST).port(8090).build();
-        final URIRegisterDTO dto2 = 
URIRegisterDTO.builder().appName("test2").rpcType(RpcTypeEnum.SPRING_CLOUD.getName()).host(HOST).port(8091).build();
+        final String returnStr = 
"{serviceId:'test1',gray:false,divideUpstreams:[{weight:50,warmup:10,protocol:"
+                + 
"'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8090',status:'true',timestamp:1637909490935}]}";
+        final String expected = 
"{\"serviceId\":\"test1\",\"gray\":false,\"divideUpstreams\":[{\"weight\":50,\"warmup\":10,\"protocol\":"
+                + 
"\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8090\",\"status\":true,\"timestamp\":1637909490935}]}";;
+        final URIRegisterDTO dto1 = URIRegisterDTO.builder().appName("test2")
+                .rpcType(RpcTypeEnum.SPRING_CLOUD.getName())
+                .host(HOST).port(8090).build();
+        final URIRegisterDTO dto2 = URIRegisterDTO.builder().appName("test2")
+                .rpcType(RpcTypeEnum.SPRING_CLOUD.getName())
+                .host(HOST).port(8091).build();
         
         List<URIRegisterDTO> list = new ArrayList<>();
         list.add(dto1);
@@ -119,13 +117,9 @@ public final class 
ShenyuClientRegisterSpringCloudServiceImplTest {
         
doReturn(false).when(shenyuClientRegisterSpringCloudService).doSubmit(any(), 
any());
         when(selectorDO.getHandle()).thenReturn(returnStr);
         String actual = 
shenyuClientRegisterSpringCloudService.buildHandle(list, selectorDO);
-        assertEquals(JsonParser.parseString(expected.replaceAll("\\d{13}", 
"0")), JsonParser.parseString(actual.replaceAll("\\d{13}", "0")));
+        assertEquals(expected, actual);
         SpringCloudSelectorHandle handle = 
GsonUtils.getInstance().fromJson(actual, SpringCloudSelectorHandle.class);
-        assertEquals(handle.getDivideUpstreams().size(), 2);
-        assertEquals(handle.getDivideUpstreams().stream().filter(r -> 
list.stream().map(dto -> CommonUpstreamUtils.buildUrl(dto.getHost(), 
dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(handle.getDivideUpstreams().stream().filter(r -> 
list.stream().map(dto -> CommonUpstreamUtils.buildUrl(dto.getHost(), 
dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
+        assertEquals(handle.getDivideUpstreams().size(), 1);
 
         list.clear();
         list.add(dto1);
@@ -136,23 +130,8 @@ public final class 
ShenyuClientRegisterSpringCloudServiceImplTest {
         actual = shenyuClientRegisterSpringCloudService.buildHandle(list, 
selectorDO);
         handle = GsonUtils.getInstance().fromJson(actual, 
SpringCloudSelectorHandle.class);
         assertEquals(handle.getDivideUpstreams().size(), 2);
-        assertEquals(handle.getDivideUpstreams().stream().filter(r -> 
list.stream().map(dto -> CommonUpstreamUtils.buildUrl(dto.getHost(), 
dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(handle.getDivideUpstreams().stream().filter(r -> 
list.stream().map(dto -> CommonUpstreamUtils.buildUrl(dto.getHost(), 
dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
-
-        list.clear();
-        list.add(dto1);
-        selectorDO = mock(SelectorDO.class);
-        
doReturn(false).when(shenyuClientRegisterSpringCloudService).doSubmit(any(), 
any());
-        
when(selectorDO.getHandle()).thenReturn("{serviceId:'test1',gray:false,divideUpstreams:[]}");
-        actual = shenyuClientRegisterSpringCloudService.buildHandle(list, 
selectorDO);
-        handle = GsonUtils.getInstance().fromJson(actual, 
SpringCloudSelectorHandle.class);
-        assertEquals(handle.getDivideUpstreams().size(), 1);
-        assertEquals(handle.getDivideUpstreams().stream().anyMatch(r -> 
r.isStatus() && 
r.getUpstreamUrl().equals(CommonUpstreamUtils.buildUrl(dto1.getHost(), 
dto1.getPort()))), true);
 
         list.clear();
-        dto1.setEventType(EventType.DELETED);
         list.add(dto1);
         selectorDO = mock(SelectorDO.class);
         
doReturn(false).when(shenyuClientRegisterSpringCloudService).doSubmit(any(), 
any());
@@ -160,12 +139,5 @@ public final class 
ShenyuClientRegisterSpringCloudServiceImplTest {
         actual = shenyuClientRegisterSpringCloudService.buildHandle(list, 
selectorDO);
         handle = GsonUtils.getInstance().fromJson(actual, 
SpringCloudSelectorHandle.class);
         assertEquals(handle.getDivideUpstreams().size(), 1);
-        assertEquals(handle.getDivideUpstreams().stream().anyMatch(r -> 
!r.isStatus() && 
r.getUpstreamUrl().equals(CommonUpstreamUtils.buildUrl(dto1.getHost(), 
dto1.getPort()))), true);
-
-        list.clear();
-        
doReturn(false).when(shenyuClientRegisterSpringCloudService).doSubmit(any(), 
any());
-        actual = shenyuClientRegisterSpringCloudService.buildHandle(list, 
selectorDO);
-        handle = GsonUtils.getInstance().fromJson(actual, 
SpringCloudSelectorHandle.class);
-        assertEquals(handle.getDivideUpstreams().stream().allMatch(r -> 
!r.isStatus()), true);
     }
 }
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImplTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImplTest.java
index 7146d20049..bed13a492b 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImplTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/register/ShenyuClientRegisterTarsServiceImplTest.java
@@ -16,21 +16,17 @@
  */
     
 package org.apache.shenyu.admin.service.register;
-    
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shenyu.admin.model.entity.MetaDataDO;
 import org.apache.shenyu.admin.model.entity.SelectorDO;
-import org.apache.shenyu.admin.service.converter.TarsSelectorHandleConverter;
 import org.apache.shenyu.admin.service.impl.MetaDataServiceImpl;
-import org.apache.shenyu.admin.utils.CommonUpstreamUtils;
-import org.apache.shenyu.common.dto.convert.selector.CommonUpstream;
 import org.apache.shenyu.common.dto.convert.selector.TarsUpstream;
 import org.apache.shenyu.common.enums.RpcTypeEnum;
 import org.apache.shenyu.common.exception.ShenyuException;
 import org.apache.shenyu.common.utils.GsonUtils;
 import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
 import org.apache.shenyu.register.common.dto.URIRegisterDTO;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.InjectMocks;
@@ -38,8 +34,6 @@ import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
-import org.springframework.test.util.ReflectionTestUtils;
-import com.google.gson.JsonParser;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -66,12 +60,6 @@ public final class ShenyuClientRegisterTarsServiceImplTest {
     @Mock
     private MetaDataServiceImpl metaDataService;
 
-    @BeforeEach
-    public void setUp() {
-        TarsSelectorHandleConverter tarsSelectorHandleConverter = new 
TarsSelectorHandleConverter();
-        ReflectionTestUtils.setField(shenyuClientRegisterTarsService, 
"tarsSelectorHandleConverter", tarsSelectorHandleConverter);
-    }
-
     @Test
     public void testRpcType() {
         assertEquals(RpcTypeEnum.TARS.getName(), 
shenyuClientRegisterTarsService.rpcType());
@@ -108,20 +96,16 @@ public final class ShenyuClientRegisterTarsServiceImplTest 
{
         final String returnStr = 
"[{upstreamUrl:'localhost:8090',weight:1,warmup:10,status:true,timestamp:1637826588267},"
                 + 
"{upstreamUrl:'localhost:8091',weight:2,warmup:10,status:true,timestamp:1637826588267}]";
         final String expected = 
"[{\"weight\":1,\"warmup\":10,\"upstreamUrl\":\"localhost:8090\",\"status\":true,\"timestamp\":1637826588267},"
-                + 
"{\"weight\":2,\"warmup\":10,\"upstreamUrl\":\"localhost:8091\",\"status\":false,\"timestamp\":1637826588267}]";
+                + 
"{\"weight\":2,\"warmup\":10,\"upstreamUrl\":\"localhost:8091\",\"status\":true,\"timestamp\":1637826588267}]";
         List<URIRegisterDTO> list = new ArrayList<>();
         
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.TARS.getName()).host("localhost").port(8090).build());
         SelectorDO selectorDO = mock(SelectorDO.class);
         when(selectorDO.getHandle()).thenReturn(returnStr);
         doReturn(false).when(shenyuClientRegisterTarsService).doSubmit(any(), 
any());
         String actual = shenyuClientRegisterTarsService.buildHandle(list, 
selectorDO);
-        assertEquals(JsonParser.parseString(expected.replaceAll("\\d{13}", 
"0")), JsonParser.parseString(actual.replaceAll("\\d{13}", "0")));
+        assertEquals(actual, expected);
         List<TarsUpstream> resultList = 
GsonUtils.getInstance().fromCurrentList(actual, TarsUpstream.class);
         assertEquals(resultList.size(), 2);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
 
         list.clear();
         
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.TARS.getName()).host("localhost").port(8092).build());
@@ -131,27 +115,14 @@ public final class 
ShenyuClientRegisterTarsServiceImplTest {
         actual = shenyuClientRegisterTarsService.buildHandle(list, selectorDO);
         resultList = GsonUtils.getInstance().fromCurrentList(actual, 
TarsUpstream.class);
         assertEquals(resultList.size(), 3);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .noneMatch(url -> url.equals(r.getUpstreamUrl()))).allMatch(r 
-> !r.isStatus()), true);
 
         list.clear();
         
list.add(URIRegisterDTO.builder().appName("test1").rpcType(RpcTypeEnum.TARS.getName()).host("localhost").port(8090).build());
         doReturn(false).when(shenyuClientRegisterTarsService).doSubmit(any(), 
any());
         selectorDO = mock(SelectorDO.class);
-        when(selectorDO.getHandle()).thenReturn("[]");
         actual = shenyuClientRegisterTarsService.buildHandle(list, selectorDO);
         resultList = GsonUtils.getInstance().fromCurrentList(actual, 
TarsUpstream.class);
         assertEquals(resultList.size(), 1);
-        assertEquals(resultList.stream().filter(r -> list.stream().map(dto -> 
CommonUpstreamUtils.buildUrl(dto.getHost(), dto.getPort()))
-                .anyMatch(url -> 
url.equals(r.getUpstreamUrl()))).allMatch(CommonUpstream::isStatus), true);
-
-        list.clear();
-        doReturn(false).when(shenyuClientRegisterTarsService).doSubmit(any(), 
any());
-        actual = shenyuClientRegisterTarsService.buildHandle(list, selectorDO);
-        resultList = GsonUtils.getInstance().fromCurrentList(actual, 
TarsUpstream.class);
-        assertEquals(resultList.stream().allMatch(r -> !r.isStatus()), true);
     }
     
     @Test
diff --git 
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstream.java
 
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstream.java
index da23771c2e..8761a71d80 100644
--- 
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstream.java
+++ 
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/selector/DubboUpstream.java
@@ -246,8 +246,6 @@ public final class DubboUpstream extends CommonUpstream {
         }
         DubboUpstream that = (DubboUpstream) o;
         return port == that.port
-                && weight == that.weight
-                && warmup == that.warmup
                 && Objects.equals(registry, that.registry)
                 && Objects.equals(appName, that.appName)
                 && Objects.equals(this.getProtocol(), that.getProtocol())
@@ -259,7 +257,7 @@ public final class DubboUpstream extends CommonUpstream {
 
     @Override
     public int hashCode() {
-        return Objects.hash(registry, appName, port, gray, weight, warmup, 
group, version);
+        return Objects.hash(registry, appName, port, gray, group, version);
     }
 
     @Override

Reply via email to