You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "arimu1 (via GitHub)" <gi...@apache.org> on 2026/08/06 01:59:13 UTC
[PR] fix: skip writes and still shut down after failed DB manager startup [logging-log4j2]
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: skip writes and still shut down after failed DB manager startup [logging-log4j2]
Posted by "ramanathan1504 (via GitHub)" <gi...@apache.org>.
ramanathan1504 merged PR #4246:
URL: https://github.com/apache/logging-log4j2/pull/4246
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: skip writes and still shut down after failed DB manager startup [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on PR #4246:
URL: https://github.com/apache/logging-log4j2/pull/4246#issuecomment-5437599938
@arimu1, could you take care of the build failures, please?
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: skip writes and still shut down after failed DB manager startup [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #4246:
URL: https://github.com/apache/logging-log4j2/pull/4246#discussion_r3870604561
##########
src/changelog/.2.x.x/4241_fix_AbstractDatabaseManager_failed_startup.xml:
##########
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <issue id="4241" link="https://github.com/apache/logging-log4j2/issues/4241"/>
Review Comment:
```suggestion
<issue id="4241" link="https://github.com/apache/logging-log4j2/issues/4241"/>
<issue id="4246" link="https://github.com/apache/logging-log4j2/pull/4246"/>
```
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: skip writes and still shut down after failed DB manager startup [logging-log4j2]
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #4246:
URL: https://github.com/apache/logging-log4j2/pull/4246#discussion_r3870630158
##########
src/changelog/.2.x.x/4241_fix_AbstractDatabaseManager_failed_startup.xml:
##########
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="fixed">
+ <issue id="4241" link="https://github.com/apache/logging-log4j2/issues/4241"/>
Review Comment:
```suggestion
<issue id="4241" link="https://github.com/apache/logging-log4j2/issues/4241"/>
<issue id="4242" link="https://github.com/apache/logging-log4j2/issues/4242"/>
```
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: skip writes and still shut down after failed DB manager startup [logging-log4j2]
Posted by "arimu1 (via GitHub)" <gi...@apache.org>.
arimu1 commented on PR #4246:
URL: https://github.com/apache/logging-log4j2/pull/4246#issuecomment-5449203821
Thanks for the review, @vy — CI should be green now.
`AbstractDatabaseAppenderTest.testAppend` was failing because the Mockito mock’s `isRunning()` is final and defaults to `false`, so `write()` returned early after the production guard. The test now uses a spy of a stub manager and calls `startup()` so the happy path still exercises `writeThrough()`.
Failed-startup behavior remains covered by `AbstractDatabaseManagerTest` (`testFailedStartupSkipsWrite`, `testFailedStartupStillShutsDown`, etc.).
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org