You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2026/03/29 01:59:37 UTC

(logging-log4cxx) 01/01: Prevent AsyncAppender buffer size change while active

This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch async_appender_buffer_resize
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit e076733799144c07cdb37605e482dbdace92ca67
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Sun Mar 29 12:58:55 2026 +1100

    Prevent AsyncAppender buffer size change while active
---
 src/main/cpp/asyncappender.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp
index 3ba0dd01..b0ebc0f4 100644
--- a/src/main/cpp/asyncappender.cpp
+++ b/src/main/cpp/asyncappender.cpp
@@ -519,6 +519,10 @@ void AsyncAppender::setBufferSize(int size)
 	}
 
 	std::lock_guard<std::mutex> lock(priv->bufferMutex);
+	if (0 < priv->eventCount)
+	{
+		throw RuntimeException(LOG4CXX_STR("AsyncAppender buffer size cannot be changed now"));
+	}
 	priv->bufferSize = (size < 1) ? 1 : size;
 	priv->buffer.resize(priv->bufferSize);
 	priv->bufferNotFull.notify_all();