Skip to content

Commit

Permalink
apply comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Technoboy- committed May 13, 2022
1 parent 68021a9 commit 392d21e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public CompletableFuture<List<String>> getListOfNamespacesAsync(String tenant) {
return ret;
}
})).reduce(CompletableFuture.completedFuture(new ArrayList<>()),
(accumulator, n) -> accumulator.thenCompose(namespaces -> n.thenCompose(m -> {
(accumulator, n) -> accumulator.thenCompose(namespaces -> n.thenApply(m -> {
namespaces.addAll(m);
return CompletableFuture.completedFuture(namespaces);
return namespaces;
}))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ protected CompletableFuture<Void> internalCreateNamespace(Policies policies) {
.thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
.thenAccept(__ -> validatePolicies(namespaceName, policies))
.thenCompose(__ -> {
CompletableFuture<Void> ret = CompletableFuture.completedFuture(null);
int maxNamespacesPerTenant = pulsar().getConfiguration().getMaxNamespacesPerTenant();
// no distributed locks are added here.In a concurrent scenario, the threshold will be exceeded.
if (maxNamespacesPerTenant > 0) {
ret = tenantResources().getListOfNamespacesAsync(namespaceName.getTenant())
return tenantResources().getListOfNamespacesAsync(namespaceName.getTenant())
.thenAccept(namespaces -> {
if (namespaces != null && namespaces.size() > maxNamespacesPerTenant) {
throw new RestException(Status.PRECONDITION_FAILED,
Expand All @@ -148,7 +147,7 @@ protected CompletableFuture<Void> internalCreateNamespace(Policies policies) {
}
});
}
return ret;
return CompletableFuture.completedFuture(null);
})
.thenCompose(__ -> namespaceResources().createPoliciesAsync(namespaceName, policies))
.thenAccept(__ -> log.info("[{}] Created namespace {}", clientAppId(), namespaceName));
Expand Down

0 comments on commit 392d21e

Please sign in to comment.