|
protected Policies getNamespacePolicies(NamespaceName namespaceName) { |
|
try { |
|
Policies policies = namespaceResources().getPolicies(namespaceName) |
|
.orElseThrow(() -> new RestException(Status.NOT_FOUND, "Namespace does not exist")); |
|
// fetch bundles from LocalZK-policies |
|
BundlesData bundleData = pulsar().getNamespaceService().getNamespaceBundleFactory() |
|
.getBundles(namespaceName).getBundlesData(); |
|
Optional<LocalPolicies> localPolicies = getLocalPolicies().getLocalPolicies(namespaceName); |
|
policies.bundles = bundleData != null ? bundleData : policies.bundles; |
|
policies.migrated = localPolicies.isPresent() ? localPolicies.get().migrated : false; |
|
if (policies.is_allow_auto_update_schema == null) { |
|
// the type changed from boolean to Boolean. return broker value here for keeping compatibility. |
|
policies.is_allow_auto_update_schema = pulsar().getConfig().isAllowAutoUpdateSchemaEnabled(); |
|
} |
|
|
|
return policies; |
|
} catch (RestException re) { |
|
throw re; |
|
} catch (Exception e) { |
|
log.error("[{}] Failed to get namespace policies {}", clientAppId(), namespaceName, e); |
|
throw new RestException(e); |
|
} |
|
|
|
} |
|
|
|
protected CompletableFuture<Policies> getNamespacePoliciesAsync(NamespaceName namespaceName) { |
|
CompletableFuture<Policies> result = new CompletableFuture<>(); |
|
namespaceResources().getPoliciesAsync(namespaceName) |
|
.thenCombine(getLocalPolicies().getLocalPoliciesAsync(namespaceName), (pl, localPolicies) -> { |
|
if (pl.isPresent()) { |
|
Policies policies = pl.get(); |
|
if (localPolicies.isPresent()) { |
|
policies.bundles = localPolicies.get().bundles; |
|
policies.migrated = localPolicies.get().migrated; |
|
} |
|
if (policies.is_allow_auto_update_schema == null) { |
|
// the type changed from boolean to Boolean. return |
|
// broker value here for keeping compatibility. |
|
policies.is_allow_auto_update_schema = pulsar().getConfig() |
|
.isAllowAutoUpdateSchemaEnabled(); |
|
} |
|
result.complete(policies); |
|
} else { |
|
result.completeExceptionally(new RestException(Status.NOT_FOUND, "Namespace does not exist")); |
|
} |
|
return null; |
|
}).exceptionally(ex -> { |
|
result.completeExceptionally(ex.getCause()); |
|
return null; |
|
}); |
|
return result; |
|
} |
Search before reporting
Read release policy
User environment
Pulsar master branch, reading the code
Issue Description
The logic for setting
policies.bundlesis slightly different inorg.apache.pulsar.broker.admin.AdminResource#getNamespacePoliciescompared to the logic in the asynchronous methodorg.apache.pulsar.broker.admin.AdminResource#getNamespacePoliciesAsync.pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
Lines 318 to 369 in e041fab
Error messages
Reproducing the issue
n/a
Additional information
No response
Are you willing to submit a PR?