pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: BonusLord (@BonusLord) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #4155: Using driver nulls out the context classloader of shared threads in ForkJoinPool.commonPool()
Date: Thu, 04 Jun 2026 19:01:49 +0000
Message-ID: <[email protected]> (raw)

**Describe the issue**
When the PostgreSQL JDBC driver is first initialized / used, logic within `LazyCleanerImpl` submits an async task to `ForkJoinPool.commonPool()` which calls `Thread.currentThread().setContextClassLoader(null);`. This permanently nulls out the context classloader of a random thread in the commonPool, which can affect the behavior of subsequent async tasks that happen to execute on the same commonPool thread that was "poisoned" by the logic in `LazyCleanerImpl`.

In my case, this causes errors in subsequent async tasks that are using the reflections8 library to discover classes, because the behavior of methods in the reflections8 library is sensitive to the context classloader of the calling thread. This breaks various functionality in our Java application.

**Driver Version?** 
42.7.11

**Java Version?**
11.0.18

**To Reproduce**
Steps to reproduce the behavior:
- Make a query to a postgres DB using the JDBC library
- Submit a bunch of tasks to `ForkJoinPool.commonPool()` which just log the name and the context classloader of the current thread
- Observe that a null context classloader is reported by some of the log messages

**Expected behaviour**
Using the postgres JDBC driver should not permanently alter the state of threads in the JVM's globally-shared common ForkJoinPool.


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #4155: Using driver nulls out the context classloader of shared threads in ForkJoinPool.commonPool()
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox