ramanathan1504 commented on code in PR #4125:
URL: https://github.com/apache/logging-log4j2/pull/4125#discussion_r3246585645
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppender.java:
##########
@@ -216,16 +210,18 @@ public void append(final LogEvent event) {
try {
tryAppend(event);
} catch (final Exception e) {
-
- if (this.retryCount != null) {
- int currentRetryAttempt = 0;
- while (currentRetryAttempt < this.retryCount) {
- currentRetryAttempt++;
+ if (this.retryCount != null && this.retryCount > 0) {
Review Comment:
if (this.retryCount != null) {
int currentRetryAttempt = 0;
while (currentRetryAttempt < this.retryCount) {
currentRetryAttempt++;
try {
tryAppend(event);
return; // Fix: Exit early on success
} catch (final Exception retryException) {
LOGGER.debug(
"Unable to write to Kafka in appender
[{}], retry attempt [{}/{}].",
getName(),
currentRetryAttempt,
this.retryCount,
retryException);
}
}
}
This still applies all three of your excellent fixes (early return, no
swallowed exceptions, and preserving the stack trace in debug mode) but
modifies fewer lines of code.
--
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]