arimu1 opened a new pull request, #4246: URL: https://github.com/apache/logging-log4j2/pull/4246
Fixes #4241 ## Description `AbstractDatabaseManager` checks `isRunning()` on the shutdown path but not on the write path. After `startupInternal()` throws, `startup()` logs the cause and leaves `running = false`. Then: - **`write()` did not check it** — kept accepting events and dereferencing state startup never assigned (NPE per event, burying the original cause). - **`shutdown()` only ran `shutdownInternal()` when `running`** — so resources acquired during a failed startup (or in the manager factory) were never released. Returns `true` anyway. This change: 1. Makes `write()` return early when `!isRunning()`, logging a single status warning instead of one failure per event. 2. Makes `shutdown()` always invoke `shutdownInternal()` once (tracked independently of `running`), so partial startup state can be cleaned up. 3. Makes `CassandraManager.shutdownInternal()` null-safe when `session` was never created (motivating failure mode from the issue / related #4242). ## Checklist * Base your changes on `2.x` branch if you are targeting Log4j 2; use `main` otherwise * `./mvnw verify` succeeds ([the build instructions](https://logging.apache.org/log4j/2.x/development.html#building)) * Non-trivial changes contain an entry file in the `src/changelog/.2.x.x` directory * Tests are provided ## Testing - JDK 17 (branch enforcer requires `[17,18)`) — JBR 17.0.14 - `./mvnw test -pl :log4j-core-test -am -Dtest=AbstractDatabaseManagerTest -Dsurefire.failIfNoSpecifiedTests=false` — **11/11 pass** - New: `testFailedStartupSkipsWrite`, `testFailedStartupStillShutsDown`, `testShutdownWithoutStartupStillRunsShutdownInternal` - Spotless check clean on `:log4j-core`, `:log4j-core-test`, `:log4j-cassandra` -- 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]
