diff --git a/CHANGES.md b/CHANGES.md index 4ec81ddac21..80a3bb1f667 100644 --- a/CHANGES.md +++ b/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) diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java index 5b2124c2c27..abbe40ef70d 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchServiceTest.java @@ -94,7 +94,7 @@ public void testUpdateBranchGrayRulesWithUpdateTwice() { 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 @@ private GrayReleaseRule instanceGrayReleaseRule() { 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; } diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java index ee419eae899..8b27e9f3ccf 100644 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java +++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/GrayReleaseRuleItemDTO.java @@ -33,6 +33,11 @@ public class GrayReleaseRuleItemDTO { private Set clientIpList; private Set 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()); }