sijie closed pull request #3260: catch bad version in persistentopic, make its 
behavior same as namespace
URL: https://github.com/apache/pulsar/pull/3260
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
index de1af662dc..aea5a169bf 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
@@ -297,7 +297,12 @@ protected void internalGrantPermissionsOnTopic(String 
role, Set<AuthAction> acti
             log.warn("[{}] Failed to grant permissions on topic {}: Namespace 
does not exist", clientAppId(),
                     topicUri);
             throw new RestException(Status.NOT_FOUND, "Namespace does not 
exist");
-        } catch (Exception e) {
+        } catch (KeeperException.BadVersionException e) {
+            log.warn("[{}] Failed to grant permissions on topic {}: concurrent 
modification", clientAppId(),
+                    topicUri);
+            throw new RestException(Status.CONFLICT, "Concurrent 
modification");
+        }
+        catch (Exception e) {
             log.error("[{}] Failed to grant permissions for topic {}", 
clientAppId(), topicUri, e);
             throw new RestException(e);
         }
@@ -330,7 +335,12 @@ protected void internalRevokePermissionsOnTopic(String 
role) {
             log.warn("[{}] Failed to revoke permissions on topic {}: Namespace 
does not exist", clientAppId(),
                     topicUri);
             throw new RestException(Status.NOT_FOUND, "Namespace does not 
exist");
-        } catch (Exception e) {
+        } catch (KeeperException.BadVersionException e) {
+            log.warn("[{}] Failed to revoke permissions on topic {}: 
concurrent modification", clientAppId(),
+                topicUri);
+            throw new RestException(Status.CONFLICT, "Concurrent 
modification");
+        }
+        catch (Exception e) {
             log.error("[{}] Failed to revoke permissions for topic {}", 
clientAppId(), topicUri, e);
             throw new RestException(e);
         }
@@ -376,6 +386,10 @@ protected void internalCreatePartitionedTopic(int 
numPartitions, boolean authori
         } catch (KeeperException.NodeExistsException e) {
             log.warn("[{}] Failed to create already existing partitioned topic 
{}", clientAppId(), topicName);
             throw new RestException(Status.CONFLICT, "Partitioned topic 
already exists");
+        } catch (KeeperException.BadVersionException e) {
+                log.warn("[{}] Failed to create partitioned topic {}: 
concurrent modification", clientAppId(),
+                        topicName);
+                throw new RestException(Status.CONFLICT, "Concurrent 
modification");
         } catch (Exception e) {
             log.error("[{}] Failed to create partitioned topic {}", 
clientAppId(), topicName, e);
             throw new RestException(e);
@@ -480,6 +494,10 @@ protected void internalDeletePartitionedTopic(boolean 
authoritative, boolean for
             log.info("[{}] Deleted partitioned topic {}", clientAppId(), 
topicName);
         } catch (KeeperException.NoNodeException nne) {
             throw new RestException(Status.NOT_FOUND, "Partitioned topic does 
not exist");
+        } catch (KeeperException.BadVersionException e) {
+            log.warn("[{}] Failed to delete partitioned topic {}: concurrent 
modification", clientAppId(),
+                    topicName);
+            throw new RestException(Status.CONFLICT, "Concurrent 
modification");
         } catch (Exception e) {
             log.error("[{}] Failed to delete partitioned topic {}", 
clientAppId(), topicName, e);
             throw new RestException(e);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to