pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [pulsar] branch master updated: Fix: NPE if messageId not present on create-sub admin-api call (#2636)
Date Mon, 24 Sep 2018 18:38:58 GMT
This is an automated email from the ASF dual-hosted git repository.

sijie 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 634726d  Fix: NPE if messageId not present on create-sub admin-api call (#2636)
634726d is described below

commit 634726dcaf8d25673868e0db638193fc7a89ab80
Author: Rajan Dhabalia <rdhabalia@apache.org>
AuthorDate: Mon Sep 24 11:38:54 2018 -0700

    Fix: NPE if messageId not present on create-sub admin-api call (#2636)
    
    ### Motivation
    
    Right now, while creating subscription if user doesn't pass message-id then broker doesn't
handle it properly which gives NPE and gives internal-server error to user.
    
    ```
    Message: null
    
    Stacktrace:
    
    java.lang.NullPointerException
            at org.apache.pulsar.broker.admin. PersistentTopicsBase.internalCreateSubscription(PersistentTopicsBase.java:885)
            at sun.reflect.GeneratedMethodAccessor199.invoke(Unknown Source)
    ```
    
    ### Modifications
    
    - take earliest-message id while creating subscription if user doesn't provide message-id.
---
 .../java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java   | 1 +
 1 file changed, 1 insertion(+)

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 9f5c2df..800545c 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
@@ -835,6 +835,7 @@ public class PersistentTopicsBase extends AdminResource {
         if (topicName.isGlobal()) {
             validateGlobalNamespaceOwnership(namespaceName);
         }
+        messageId = messageId == null ? (MessageIdImpl) MessageId.earliest : messageId;
         log.info("[{}][{}] Creating subscription {} at message id {}", clientAppId(), topicName,
                 subscriptionName, messageId);
 


Mime
View raw message