@@ -355,11 +355,14 @@ public synchronized void removeConsumer(Consumer consumer, boolean isResetCursor
355355 if (dispatcher != null && dispatcher .getConsumers ().isEmpty ()) {
356356 deactivateCursor ();
357357 // Remove the cursor from the waiting cursors list.
358- // For durable cursors, we should *not* cancel the pending read. This is because internally,
359- // in the dispatcher implementations, there is a "havePendingRead" flag that is not reset. If the pending
360- // read is cancelled, the dispatcher will not continue reading from the managed ledger when a new
361- // consumer is added to the dispatcher since based on the "havePendingRead" state, it will continue to
362- // expect that a read is pending and will not submit a new read.
358+ // For durable cursors, we should *not* cancel the pending read with cursor.cancelPendingReadRequest.
359+ // This is because internally, in the dispatcher implementations, there is a "havePendingRead" flag
360+ // that is not reset. If the pending read is cancelled, the dispatcher will not continue reading from
361+ // the managed ledger when a new consumer is added to the dispatcher since based on the "havePendingRead"
362+ // state, it will continue to expect that a read is pending and will not submit a new read.
363+ // For non-durable cursors, there's no difference since the cursor is not expected to be used again.
364+
365+ // remove waiting cursor from the managed ledger, this applies to both durable and non-durable cursors.
363366 topic .getManagedLedger ().removeWaitingCursor (cursor );
364367
365368 if (!cursor .isDurable ()) {
0 commit comments