Skip to content

Commit 3c0bbee

Browse files
authored
[improve][broker] Avoid printing log for IncompatibleSchemaException in ServerCnx (#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
1 parent 5e5d514 commit 3c0bbee

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
@@ -1627,8 +1627,12 @@ protected void handleProducer(final CommandProducer cmdProducer) {
16271627
BrokerServiceException.getClientErrorCode(exception),
16281628
message);
16291629
}
1630-
log.error("Try add schema failed, remote address {}, topic {}, producerId {}", remoteAddress,
1631-
topicName, producerId, exception);
1630+
var cause = FutureUtil.unwrapCompletionException(exception);
1631+
if (!(cause instanceof IncompatibleSchemaException)) {
1632+
log.error("Try add schema failed, remote address {}, topic {}, producerId {}",
1633+
remoteAddress,
1634+
topicName, producerId, exception);
1635+
}
16321636
producers.remove(producerId, producerFuture);
16331637
return null;
16341638
});

0 commit comments

Comments
 (0)