diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java index 8006b895c0751..26dbd22aaee6a 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java @@ -905,14 +905,14 @@ protected void handleSubscribe(final CommandSubscribe subscribe) { final String subscriptionName = subscribe.getSubscription(); final SubType subType = subscribe.getSubType(); - final String consumerName = subscribe.getConsumerName(); + final String consumerName = subscribe.hasConsumerName() ? subscribe.getConsumerName() : ""; final boolean isDurable = subscribe.isDurable(); final MessageIdImpl startMessageId = subscribe.hasStartMessageId() ? new BatchMessageIdImpl( subscribe.getStartMessageId().getLedgerId(), subscribe.getStartMessageId().getEntryId(), subscribe.getStartMessageId().getPartition(), subscribe.getStartMessageId().getBatchIndex()) : null; final int priorityLevel = subscribe.hasPriorityLevel() ? subscribe.getPriorityLevel() : 0; - final boolean readCompacted = subscribe.isReadCompacted(); + final boolean readCompacted = subscribe.hasReadCompacted() && subscribe.isReadCompacted(); final Map metadata = CommandUtils.metadataFromCommand(subscribe); final InitialPosition initialPosition = subscribe.getInitialPosition(); final long startMessageRollbackDurationSec = subscribe.hasStartMessageRollbackDurationSec()