You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2021/08/15 01:12:43 UTC

[pulsar] branch master updated: Use getIfValid to avoid handleMetadataStoreNotification swallow exception (#11656) (#11656)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 64aa64e  Use getIfValid to avoid handleMetadataStoreNotification swallow exception (#11656) (#11656)
64aa64e is described below

commit 64aa64e5b487b705da20e10e990ba56f7252b13e
Author: GuoJiwei <te...@apache.org>
AuthorDate: Sun Aug 15 09:11:21 2021 +0800

    Use getIfValid to avoid handleMetadataStoreNotification swallow exception (#11656) (#11656)
---
 .../pulsar/common/naming/NamespaceBundleFactory.java       | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java
index c1c9833..2d94c5f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java
@@ -159,14 +159,16 @@ public class NamespaceBundleFactory {
 
     private void handleMetadataStoreNotification(Notification n) {
         if (n.getPath().startsWith(LOCAL_POLICIES_ROOT)) {
-            final NamespaceName namespace = NamespaceName.get(getNamespaceFromPoliciesPath(n.getPath()));
-
             try {
-                LOG.info("Policy updated for namespace {}, refreshing the bundle cache.", namespace);
-                // Trigger a background refresh to fetch new bundle data from the policies
-                bundlesCache.synchronous().invalidate(namespace);
+                final Optional<NamespaceName> namespace = NamespaceName.getIfValid(
+                        getNamespaceFromPoliciesPath(n.getPath()));
+                if (namespace.isPresent()) {
+                    LOG.info("Policy updated for namespace {}, refreshing the bundle cache.", namespace);
+                    // Trigger a background refresh to fetch new bundle data from the policies
+                    bundlesCache.synchronous().invalidate(namespace.get());
+                }
             } catch (Exception e) {
-                LOG.error("Failed to update the policy change for ns {}", namespace, e);
+                LOG.error("Failed to update the policy change for path {}", n.getPath(), e);
             }
         }
     }