Skip to content

Commit 26a990b

Browse files
RobertIndiesrinath-ctds
authored andcommitted
[improve][broker] Avoid printing log for IncompatibleSchemaException in ServerCnx (apache#23938)
### Motivation If the producer is created with some schema error, the broker will print many error logs like this: ``` ERROR org.apache.pulsar.broker.service.ServerCnx - Try add schema failed, remote address xxx java.util.concurrent.CompletionException: org.apache.pulsar.broker.service.schema.exceptions.IncompatibleSchemaException: Producers cannot connect or send message without a schema to topics with a schemawhen SchemaValidationEnforced is enabled ``` This error can be reported to the client and not need to print it in the broker. ### Modifications - Avoid printing log for IncompatibleSchemaException in ServerCnx (cherry picked from commit 3c0bbee) (cherry picked from commit 0de057a)
1 parent 634666c commit 26a990b

File tree

1 file changed

+6
-2
lines changed
  • pulsar-broker/src/main/java/org/apache/pulsar/broker/service

1 file changed

+6
-2
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,12 @@ protected void handleProducer(final CommandProducer cmdProducer) {
15581558
BrokerServiceException.getClientErrorCode(exception),
15591559
message);
15601560
}
1561-
log.error("Try add schema failed, remote address {}, topic {}, producerId {}", remoteAddress,
1562-
topicName, producerId, exception);
1561+
var cause = FutureUtil.unwrapCompletionException(exception);
1562+
if (!(cause instanceof IncompatibleSchemaException)) {
1563+
log.error("Try add schema failed, remote address {}, topic {}, producerId {}",
1564+
remoteAddress,
1565+
topicName, producerId, exception);
1566+
}
15631567
producers.remove(producerId, producerFuture);
15641568
return null;
15651569
});

0 commit comments

Comments
 (0)