Message-ID: From: "davecramer (@davecramer)" To: "pgjdbc/pgjdbc" Date: Thu, 04 Dec 2025 10:44:40 +0000 Subject: Re: [pgjdbc/pgjdbc] PR #3886: fix: avoid memory leaks in Java <= 21 caused by Thread.inheritedAccessControlContext In-Reply-To: References: List-Id: X-GitHub-Author-Login: davecramer X-GitHub-Comment-Id: 3611459558 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 3886 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/pull/3886#issuecomment-3611459558 Content-Type: text/plain; charset=utf-8 Using claude it suggested ``` ForkJoinPool.commonPool().execute(() -> { RefQueueBlocker blocker = new RefQueueBlocker<>(queue, threadName, threadTtl, () -> !checkEmpty()); while (!checkEmpty()) { try { ref.onClean(true); ForkJoinPool.managedBlock(blocker); Node ref = (Node) blocker.drainOne(); if (ref != null) { ref.onClean(true); } } catch (InterruptedException e) { if (checkEmpty()) { LOGGER.log(Level.FINE, "Cleanup queue is empty, and got interrupt, will terminate the cleanup thread"); break; } LOGGER.log(Level.FINE, "Ignoring interrupt since the cleanup queue is non-empty"); } catch (Throwable e) { LOGGER.log(Level.WARNING, "Unexpected exception while executing onClean", e); } } }); ``` as a simplification to the try catch logic Also had this to say 5. Missing edge cases - What happens if ForkJoinPool.commonPool() is unavailable (custom security manager)? - No handling for RejectedExecutionException from execute() - The threadFactory.newThread() can return null but only logs a warning -