eolivelli commented on a change in pull request #9763:
URL: https://github.com/apache/pulsar/pull/9763#discussion_r584603581
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentReplicator.java
##########
@@ -190,12 +190,14 @@ protected long getNumberOfEntriesInBacklog() {
@Override
protected void disableReplicatorRead() {
- // deactivate cursor after successfully close the producer
- this.cursor.setInactive();
+ if (this.cursor != null) {
+ // deactivate cursor after successfully close the producer
+ this.cursor.setInactive();
Review comment:
this is not enough to prevent an NPE here.
We should sample the reference and then use the local ref
```
ManagedCursor currentCursor = this.cursor;
if (localCursor != null) {
localCursor.setInactive();
}
```
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentReplicator.java
##########
@@ -441,10 +443,12 @@ public void readEntriesComplete(List<Entry> entries,
Object ctx) {
}
public void updateCursorState() {
- if (producer != null && producer.isConnected()) {
- this.cursor.setActive();
- } else {
- this.cursor.setInactive();
+ if (this.cursor != null) {
Review comment:
the same here
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentReplicator.java
##########
@@ -688,7 +692,7 @@ public void updateRates() {
}
public ReplicatorStats getStats() {
- stats.replicationBacklog = cursor.getNumberOfEntriesInBacklog(false);
+ stats.replicationBacklog = cursor != null ?
cursor.getNumberOfEntriesInBacklog(false) : 0;
Review comment:
and here
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]