Skip to content

Commit

Permalink
Fix breaking change of the deprecated constructor of PersistentMessag…
Browse files Browse the repository at this point in the history
…eExpiryMonitor

### Motivation

apache#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.
  • Loading branch information
BewareMyPower committed Jul 12, 2023
1 parent 643ffad commit 5c55633
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ public PersistentMessageExpiryMonitor(PersistentTopic topic, String subscription
&& 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;
Expand Down

0 comments on commit 5c55633

Please sign in to comment.