BewareMyPower commented on a change in pull request #13606:
URL: https://github.com/apache/pulsar/pull/13606#discussion_r778201334
##########
File path:
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
##########
@@ -741,11 +741,10 @@ public void connectionOpened(final ClientCnx cnx) {
boolean isDurable = subscriptionMode == SubscriptionMode.Durable;
MessageIdData startMessageIdData = null;
- if (isDurable) {
- // For regular durable subscriptions, the message id from where to
restart will be determined by the broker.
- startMessageIdData = null;
- } else if (startMessageId != null) {
- // For non-durable we are going to restart from the next entry
+
+ // For regular durable subscriptions, the message id from where to
restart will be determined by the broker.
+ // For non-durable we are going to restart from the next entry.
+ if (!isDurable && startMessageId != null) {
Review comment:
I suggest changing `startMessageIdData` to a `final` variable so that
code could be more clear and the variable cannot be assigned twice or more.
i.e.
```java
final MessageIdData startMessageIdData;
if (!isDurable && startMessageId != null) {
// For non-durable we are going to restart from the next entry
startMessageIdData = new MessageIdData()
.setLedgerId(startMessageId.getLedgerId())
.setEntryId(startMessageId.getEntryId())
.setBatchIndex(startMessageId.getBatchIndex());
} else {
startMessageIdData = null;
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]