[java] LoggingOptionsTest#captureStderrDuring doesn't clean up leaked root-logger handlers
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Open java/test/org/openqa/selenium/grid/log/LoggingOptionsTest.java and compare captureStderrDuring with the already-fixed captureStdOutAndErrDuring helper. Trace the root logger handlers around the temporary System.err swap, then run the relevant LoggingOptionsTest tests. Done means handlers added during capture are removed and closed during cleanup, preventing later output pollution.
Written by the indexing model from the issue text.
Description
Feature and motivation
Follow-up from #17841 (found by an AI agent while fixing two qodo-code-review findings on that PR's tests, deliberately left out to keep that PR scoped to the findings actually flagged there).
java/test/org/openqa/selenium/grid/log/LoggingOptionsTest.java has two stream-capture helpers: captureStdOutAndErrDuring and captureStderrDuring. LoggingOptions.configureLogging() installs root-logger handlers bound to whatever System.out/System.err are current at call time (via getOutputStream()). If a test temporarily swaps those streams to capture output, those handlers persist after the helper restores the real streams, keep writing into the now-discarded capture buffer, and can pollute later tests/output in the same JVM.
This exact bug was already fixed in captureStdOutAndErrDuring (PR #17841, snapshotting the root logger's handlers before the wrapped action and removing/closing anything added during it), but captureStderrDuring — the simpler, stderr-only variant used by other tests in the same file — was never given the same treatment.
Suggested fix
Mirror captureStdOutAndErrDuring's fix in captureStderrDuring: snapshot LogManager.getLogManager().getLogger("").getHandlers() before swapping System.err, and in the finally block, remove+close any handler that wasn't present in that snapshot.
Context
Found while addressing qodo-code-review findings on #17841 (the same PR that fixed the sibling helper). Not itself flagged by a review comment, so tracked here rather than folded into that PR's scope.
- Dominant language
- Java
- Stars
- 34.5k
- Forks
- 8.7k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 91
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SeleniumHQ/selenium
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
SeleniumHQ/selenium#17836 ·
-
A-needs-triaging B-grid C-java D-chrome I-defect I-regression OS-linux
Difficulty 3/5 1-2 days Newbie friendliness 62/100
SeleniumHQ/selenium#18062 · 2 comments ·
-
Latent NPE risk at ~25 call sites of Json.toType() (surfaced by nullability annotation in #17802) Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
SeleniumHQ/selenium#18031 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
SeleniumHQ/selenium#18020 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
SeleniumHQ/selenium#18019 · 7 comments ·
All issues in SeleniumHQ/selenium
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100