Browse Source

Fix the npe issue for old version of gray release rules (#4382)

Jason Song 2 năm trước cách đây
mục cha
commit
cd77fd5abf

+ 1 - 0
CHANGES.md

@@ -7,5 +7,6 @@ Apollo 2.0.1
 ------------------
 * [Upgrade spring boot to fix search user issue](https://github.com/apolloconfig/apollo/pull/4366)
 * [Fix search user duplication issue](https://github.com/apolloconfig/apollo/pull/4371)
+* [Fix the npe issue for old version of gray release rules](https://github.com/apolloconfig/apollo/pull/4382)
 ------------------
 All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/12?closed=1)

+ 2 - 2
apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java

@@ -94,7 +94,7 @@ public class NamespaceBranchServiceTest extends AbstractIntegrationTest {
     namespaceBranchService.updateBranchGrayRules(testApp, testCluster, testNamespace, testBranchName, firstRule);
 
     GrayReleaseRule secondRule = instanceGrayReleaseRule();
-    secondRule.setRules("[{\"clientAppId\":\"branch-test\",\"clientIpList\":[\"10.38.57.112\"]}]");
+    secondRule.setRules("[{\"clientAppId\":\"branch-test\",\"clientIpList\":[\"10.38.57.112\"],\"clientLabelList\":[\"branch-test\"]}]");
     namespaceBranchService.updateBranchGrayRules(testApp, testCluster, testNamespace, testBranchName, secondRule);
 
     GrayReleaseRule
@@ -200,7 +200,7 @@ public class NamespaceBranchServiceTest extends AbstractIntegrationTest {
     rule.setNamespaceName(testNamespace);
     rule.setBranchName(testBranchName);
     rule.setBranchStatus(NamespaceBranchStatus.ACTIVE);
-    rule.setRules("[{\"clientAppId\":\"test\",\"clientIpList\":[\"1.0.0.4\"]}]");
+    rule.setRules("[{\"clientAppId\":\"test\",\"clientIpList\":[\"1.0.0.4\"],\"clientLabelList\":[]}]");
     return rule;
   }
 

+ 5 - 0
apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java

@@ -33,6 +33,11 @@ public class GrayReleaseRuleItemDTO {
   private Set<String> clientIpList;
   private Set<String> clientLabelList;
 
+  // this default constructor is for json deserialize use, to make sure all fields are initialized
+  public GrayReleaseRuleItemDTO() {
+    this("");
+  }
+
   public GrayReleaseRuleItemDTO(String clientAppId) {
     this(clientAppId, Sets.newHashSet(), Sets.newHashSet());
   }