swebb2066 commented on code in PR #586:
URL: https://github.com/apache/logging-log4cxx/pull/586#discussion_r2756932288


##########
src/test/cpp/asyncappendertestcase.cpp:
##########
@@ -739,6 +740,62 @@ class AsyncAppenderTestCase : public 
AppenderSkeletonTestCase
                }
 #endif // LOG4CXX_ASYNC_BUFFER_SUPPORTS_FMT
 
+               /**
+                * Tests that resizing the buffer when data is wrapped around 
(index > size)
+                * does not cause a crash or data loss.
+                */
+               void testBufferResizeWraparound()
+               {
+                       int initialSize = 10;
+                       int newSize = 20;
+
+                       auto asyncAppender = std::make_shared<AsyncAppender>();
+                       asyncAppender->setBufferSize(initialSize);
+
+                       auto vectorAppender = 
std::make_shared<VectorAppender>();

Review Comment:
   VectorAppender cannot be used as it is not thread safe. I Suggest using the 
following thread safe appender instead:
   ```
                        class CountingAppender : public AppenderSkeleton
                        {
                                public:
                                        std::atomic<int> count { 0 };
   
                                        void close() override
                                        {}
   
                                        void append(const spi::LoggingEventPtr& 
/*event*/, helpers::Pool& /*p*/) override
                                        {
                                                ++count;
                                        }
   
                                        bool requiresLayout() const override
                                        {
                                                return false;
                                        }
                        };
   ```
   



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