gharris1727 commented on code in PR #15922:
URL: https://github.com/apache/kafka/pull/15922#discussion_r1599430843
##########
log4j-appender/src/main/java/org/apache/kafka/log4jappender/KafkaLog4jAppender.java:
##########
@@ -349,8 +349,14 @@ protected Producer<byte[], byte[]>
getKafkaProducer(Properties props) {
protected void append(LoggingEvent event) {
String message = subAppend(event);
LogLog.debug("[" + new Date(event.getTimeStamp()) + "]" + message);
- Future<RecordMetadata> response = producer.send(
- new ProducerRecord<>(topic,
message.getBytes(StandardCharsets.UTF_8)));
+ Future<RecordMetadata> response;
Review Comment:
I don't think so. The internal state of the producer is the source of truth
on whether this is closed, not the `closed` variable. A race condition could
still cause an IllegalStateException to occur even if there's an if-condition
first.
--
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]