Copilot commented on code in PR #7043:
URL: https://github.com/apache/shenyu/pull/7043#discussion_r4032631918


##########
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-kafka/src/main/java/org/apache/shenyu/plugin/logging/kafka/client/KafkaLogCollectClient.java:
##########
@@ -140,11 +140,11 @@ public void consume0(@NonNull final 
List<ShenyuRequestLog> logs) {
                         LOG.error("kafka push logs error", exception);
                     }
                 });
-                producer.flush();
             } catch (Exception e) {
                 LOG.error("kafka push logs error", e);
             }
         });
+        producer.flush();

Review Comment:
   `KafkaProducer.flush()` can throw `KafkaException`/`InterruptException` (and 
can fail if the producer is closed), but this call is now outside the 
per-record `try` block. The exception therefore escapes `consume0`, causing the 
collector's outer loop to discard the drained batch and back off instead of 
logging the send failure as before. Keep the batch-level flush, but wrap it in 
the same error handling (or otherwise handle the failure locally).



-- 
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]

Reply via email to