Jason918 commented on code in PR #15051:
URL: https://github.com/apache/pulsar/pull/15051#discussion_r846947659
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:
##########
@@ -992,32 +992,29 @@ protected void handleSubscribe(final CommandSubscribe
subscribe) {
}
if (existingConsumerFuture != null) {
- if (existingConsumerFuture.isDone() &&
!existingConsumerFuture.isCompletedExceptionally()) {
- Consumer consumer =
existingConsumerFuture.getNow(null);
- log.info("[{}] Consumer with the same id is already
created:"
- + " consumerId={}, consumer={}",
- remoteAddress, consumerId, consumer);
- commandSender.sendSuccessResponse(requestId);
- return null;
- } else {
+ if (!existingConsumerFuture.isDone()){
// There was an early request to create a consumer
with same consumerId. This can happen
// when
// client timeout is lower the broker timeouts. We
need to wait until the previous
// consumer
// creation request either complete or fails.
log.warn("[{}][{}][{}] Consumer with id is already
present on the connection,"
- + " consumerId={}", remoteAddress, topicName,
subscriptionName, consumerId);
- ServerError error = null;
- if (!existingConsumerFuture.isDone()) {
- error = ServerError.ServiceNotReady;
- } else {
- error = getErrorCode(existingConsumerFuture);
- consumers.remove(consumerId,
existingConsumerFuture);
- }
- commandSender.sendErrorResponse(requestId, error,
+ + " consumerId={}", remoteAddress, topicName,
subscriptionName, consumerId);
+ commandSender.sendErrorResponse(requestId,
ServerError.ServiceNotReady,
"Consumer is already present on the
connection");
- return null;
+ } else if
(existingConsumerFuture.isCompletedExceptionally()){
+ ServerError error =
getErrorCode(existingConsumerFuture);
Review Comment:
Better to keep the warning log here too.
--
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]