Message-ID: From: "vlsi (@vlsi)" To: "pgjdbc/pgjdbc" Date: Fri, 19 Jun 2026 06:40:11 +0000 Subject: [pgjdbc/pgjdbc] PR #4197: test: silence expected SSPI warning stack trace in SSPIClientWaffleTest List-Id: X-GitHub-Additions: 6 X-GitHub-Author-Id: 213894 X-GitHub-Author-Login: vlsi X-GitHub-Base: master X-GitHub-Changed-Files: 1 X-GitHub-Commits: 1 X-GitHub-Deletions: 0 X-GitHub-Head-Branch: claude/condescending-hamilton-9a97ae X-GitHub-Head-SHA: 97947f27d380f507550927ce02969e9f0520122a X-GitHub-Issue: 4197 X-GitHub-Labels: building-and-testing X-GitHub-Merge-SHA: 9f96280d9630eb85a22fa4bd3d0540b7a89d838c X-GitHub-Merged-By: vlsi X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: merged X-GitHub-Type: pull_request X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/pull/4197 Content-Type: text/plain; charset=utf-8 ## Problem `SSPIClientWaffleTest.reportsUnavailableAndWarnsWhenWaffleIsMissing()` deliberately hides the `waffle.*` packages via a custom classloader to verify that `SSPIClient.isWaffleAvailable()` degrades gracefully. As designed, the probe logs the expected `ClassNotFoundException` at `WARNING`. That record propagates to the root console handler, so the build output shows a full stack trace on stderr: ``` AVERTISSEMENT: SSPI unavailable (no Waffle/JNA libraries?) java.lang.ClassNotFoundException: waffle.windows.auth.impl.WindowsSecurityContextImpl at ...SSPIClientWaffleTest$WaffleHidingClassLoader.loadClass(...) ... ``` The exception is expected — it is the whole point of the negative test — but the stack trace reads like a real failure. ## Fix Disable parent-handler propagation on the `org.postgresql.sspi.SSPIClient` logger for the duration of the test and restore it in `finally`. The locally added handler still captures the record, so the `WARNING`-was-emitted assertion is unchanged. This keeps the change narrowly scoped to a single leaf logger, so `@Isolated` is not required: nothing else logs through `org.postgresql.sspi.SSPIClient` concurrently (the default JUnit execution mode is `SAME_THREAD`, and `SSPITest` is Windows-only). 🤖 Generated with [Claude Code](https://claude.com/claude-code) diff --git a/pgjdbc/src/test/java/org/postgresql/test/sspi/SSPIClientWaffleTest.java b/pgjdbc/src/test/java/org/postgresql/test/sspi/SSPIClientWaffleTest.java index 5b47fbdc99..a03cfd1e5b 100644 --- a/pgjdbc/src/test/java/org/postgresql/test/sspi/SSPIClientWaffleTest.java +++ b/pgjdbc/src/test/java/org/postgresql/test/sspi/SSPIClientWaffleTest.java @@ -78,12 +78,18 @@ public void close() { }; handler.setLevel(Level.ALL); logger.addHandler(handler); + // The probe logs the expected ClassNotFoundException at WARNING. Keep it from reaching the + // console handlers so the deliberate failure does not show up as stderr noise in the build; + // the locally added handler still captures the record for the assertion below. + boolean useParentHandlers = logger.getUseParentHandlers(); + logger.setUseParentHandlers(false); try { assertFalse(isWaffleAvailable(new WaffleHidingClassLoader(getClass().getClassLoader()))); boolean warned = records.stream().anyMatch(record -> record.getLevel() == Level.WARNING && String.valueOf(record.getMessage()).contains(UNAVAILABLE_MESSAGE)); assertTrue(warned, "expected a WARNING containing: " + UNAVAILABLE_MESSAGE); } finally { + logger.setUseParentHandlers(useParentHandlers); logger.removeHandler(handler); } }