Skip to content

Commit 0de057a

Browse files
committed
[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)
1 parent 35c97fc commit 0de057a

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
@@ -1556,8 +1556,12 @@ protected void handleProducer(final CommandProducer cmdProducer) {
15561556
BrokerServiceException.getClientErrorCode(exception),
15571557
message);
15581558
}
1559-
log.error("Try add schema failed, remote address {}, topic {}, producerId {}", remoteAddress,
1560-
topicName, producerId, exception);
1559+
var cause = FutureUtil.unwrapCompletionException(exception);
1560+
if (!(cause instanceof IncompatibleSchemaException)) {
1561+
log.error("Try add schema failed, remote address {}, topic {}, producerId {}",
1562+
remoteAddress,
1563+
topicName, producerId, exception);
1564+
}
15611565
producers.remove(producerId, producerFuture);
15621566
return null;
15631567
});

0 commit comments

Comments
 (0)