Visitar URL original
fix: catch SecurityException from setContextClassLoader on ForkJoinPool workers by vlsi · Pull Request #3962 · pgjdbc/pgjdbc · GitHub
Skip to content

fix: catch SecurityException from setContextClassLoader on ForkJoinPool workers - #3962

Merged
vlsi merged 1 commit into
pgjdbc:masterfrom
vlsi:fix/security-exception-setContextClassLoader
Mar 14, 2026
Merged

vlsi merged 1 commit into
pgjdbc:masterfrom
vlsi:fix/security-exception-setContextClassLoader

Conversation

@vlsi

@vlsi vlsi commented Mar 14, 2026

Copy link
Copy Markdown
Member

InnocuousForkJoinWorkerThread (used by ForkJoinPool.commonPool() under certain security configurations) throws SecurityException when setContextClassLoader is called. This crashed the cleanup thread, disabling phantom-reference-based leak detection for the rest of the JVM lifetime.

Wrap the call in try-catch since it is best-effort: ForkJoinPool does not inherit contextClassLoader from the submitting thread, but custom thread factories might, so we still attempt to nullify it.

Fixes #3953

…ol workers

InnocuousForkJoinWorkerThread (used by ForkJoinPool.commonPool() under
certain security configurations) throws SecurityException when
setContextClassLoader is called. This crashed the cleanup thread,
disabling phantom-reference-based leak detection for the rest of the
JVM lifetime.

Wrap the call in try-catch since it is best-effort: ForkJoinPool does
not inherit contextClassLoader from the submitting thread, but custom
thread factories might, so we still attempt to nullify it.

Fixes pgjdbc#3953

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vlsi
vlsi force-pushed the fix/security-exception-setContextClassLoader branch from 5d0147b to e4eacfc Compare March 14, 2026 08:16
@vlsi

vlsi commented Mar 14, 2026

Copy link
Copy Markdown
Member Author

I couldn't make the test run with the SecurityManager as Gradle overrides it.

@vlsi
vlsi merged commit 3ba467f into pgjdbc:master Mar 14, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"ForkJoinPool.commonPool-worker-1" java.lang.SecurityException: setContextClassLoader

1 participant