From 551652a1d7cdef1becd915fc15e291483c15b317 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Mon, 30 Sep 2024 10:34:55 +0200 Subject: [PATCH] Synchronize `JeroMqAppender` test methods The `sendRcFalse` and `sendRcTrue` fields of `JeroMqAppender` are accessed without the necessary synchronization, which causes some test failures. --- .../appender/mom/jeromq/JeroMqAppender.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppender.java index 2167a3dc60e..c2598c1332c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppender.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jeromq/JeroMqAppender.java @@ -224,22 +224,30 @@ public boolean stop(final long timeout, final TimeUnit timeUnit) { return stopped; } - // not public, handy for testing - int getSendRcFalse() { + /** + * Used in tests + */ + synchronized int getSendRcFalse() { return sendRcFalse; } - // not public, handy for testing - int getSendRcTrue() { + /** + * Used in tests + */ + synchronized int getSendRcTrue() { return sendRcTrue; } - // not public, handy for testing - void resetSendRcs() { + /** + * Used in tests + */ + synchronized void resetSendRcs() { sendRcTrue = sendRcFalse = 0; } - // not public, handy for testing + /** + * Used in tests + */ JeroMqManager getManager() { return manager; }