kdgregory / log4j-aws-appenders

Appenders for Log4J 1.2.x, Log4J 2.x, and Logback that write to AWS destinations.
Apache License 2.0
67 stars 18 forks source link

Synchronous mode: queue messages if writer not initialized #170

Closed kdgregory closed 1 year ago

kdgregory commented 1 year ago

When running in synchronous mode, the LogWriter.addMessage() will attempt to send the batch on the invoking thread. However, this causes a race condition in the case of long-running initialization (made worse because we won't delay appender startup in 3.1.0).

Add a conditional test on isRunning at AbstractLogWriter line 233.

kdgregory commented 1 year ago

After looking at the code, initialization has to be moved off the writer thread. That should be the main part of this work.