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

xyz pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.10 by this push:
     new 5c556334a0d Fix breaking change of the deprecated constructor of 
PersistentMessageExpiryMonitor
5c556334a0d is described below

commit 5c556334a0ddc666c2556d1cdf5f0ddce14e68ce
Author: Yunze Xu <[email protected]>
AuthorDate: Wed Jul 12 16:07:11 2023 +0800

    Fix breaking change of the deprecated constructor of 
PersistentMessageExpiryMonitor
    
    ### Motivation
    
    https://github.com/apache/pulsar/pull/20781 adds a new constructor to
    `PersistentMessageExpiryMonitor` and initialize the old constructor with
    
    ```java
    this.topic = subscription.topic;
    ```
    
    NPE will happen when `subscription` is null. However, it's allowed to
    pass a null `subscription` for test because methods like
    `findEntryFailed` don't depend on the `topic` field.
    
    ### Modifications
    
    Add the null check and mark the old constructor as deprecated.
---
 .../broker/service/persistent/PersistentMessageExpiryMonitor.java      | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java
index 35c6b807589..1408811017d 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java
@@ -72,10 +72,11 @@ public class PersistentMessageExpiryMonitor implements 
FindEntryCallback {
                 && 
this.cursor.getManagedLedger().getConfig().isAutoSkipNonRecoverableData();
     }
 
+    @Deprecated
     public PersistentMessageExpiryMonitor(String topicName, String 
subscriptionName, ManagedCursor cursor,
                                           PersistentSubscription subscription) 
{
         this.topicName = topicName;
-        this.topic = subscription.topic;
+        this.topic = (subscription == null) ? null : (PersistentTopic) 
subscription.getTopic();
         this.cursor = cursor;
         this.subName = subscriptionName;
         this.subscription = subscription;

Reply via email to