From 707cb1a8c9a916673aec2525cc7cecdb5bf0487b Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Fri, 2 Jul 2021 20:21:31 +0200 Subject: [PATCH] Fixed using CommandSubscribe.getConsumerName() without checking (#11199) --- .../main/java/org/apache/pulsar/broker/service/ServerCnx.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 13408bc645912..fed73ce75c95a 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()