Skip to content

Commit 30da4ee

Browse files
authored
Merge pull request apolloconfig#1346 from nobodyiam/fix-public-appnamespace-deleted-and-recreated
fix the situation when some public app namespace is deleted and recreated in another app
2 parents 5966002 + 0072340 commit 30da4ee

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ private void instanceOfAppNamespaceInAllCluster(String appId, String namespaceNa
131131
List<Cluster> clusters = clusterService.findParentClusters(appId);
132132

133133
for (Cluster cluster : clusters) {
134+
135+
// in case there is some dirty data, e.g. public namespace deleted in other app and now created in this app
136+
if (!namespaceService.isNamespaceUnique(appId, cluster.getName(), namespaceName)) {
137+
continue;
138+
}
139+
134140
Namespace namespace = new Namespace();
135141
namespace.setClusterName(cluster.getName());
136142
namespace.setAppId(appId);

apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/service/AppNamespaceServiceWithCache.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ private void handleDeletedAppNamespaces(Set<Long> deletedIds) {
247247
}
248248
appNamespaceCache.remove(assembleAppNamespaceKey(deleted));
249249
if (deleted.isPublic()) {
250-
publicAppNamespaceCache.remove(deleted.getName());
250+
AppNamespace publicAppNamespace = publicAppNamespaceCache.get(deleted.getName());
251+
// in case there is some dirty data, e.g. public namespace deleted in some app and now created in another app
252+
if (publicAppNamespace == deleted) {
253+
publicAppNamespaceCache.remove(deleted.getName());
254+
}
251255
}
252256
logger.info("Found AppNamespace deleted, {}", deleted);
253257
}

0 commit comments

Comments
 (0)