Title: [Bug] Memory Leak and Stats Pollution via unmanaged ThreadLocal in ThreadLocalStatisticsCollector · Issue #266 · graphql-java/java-dataloader · GitHub
Open Graph Title: [Bug] Memory Leak and Stats Pollution via unmanaged ThreadLocal in ThreadLocalStatisticsCollector · Issue #266 · graphql-java/java-dataloader
X Title: [Bug] Memory Leak and Stats Pollution via unmanaged ThreadLocal in ThreadLocalStatisticsCollector · Issue #266 · graphql-java/java-dataloader
Description: Describe the bug There is a potential Unintentional ThreadLocal Leak (UTL) in ThreadLocalStatisticsCollector. The class relies on consumers manually calling resetThread() at "request boundaries" to clear the ThreadLocal Open Graph Description: Describe the bug There is a potential Unintentional ThreadLocal Leak (UTL) in ThreadLocalStatisticsCollector. The class relies on consumers manually calling resetThread() at "request boundaries" to...
X Description: Describe the bug There is a potential Unintentional ThreadLocal Leak (UTL) in ThreadLocalStatisticsCollector. The class relies on consumers manually calling resetThread() at "request boundarie...
Opengraph URL: https://github.com/graphql-java/java-dataloader/issues/266
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug] Memory Leak and Stats Pollution via unmanaged ThreadLocal in ThreadLocalStatisticsCollector","articleBody":"**Describe the bug**\nThere is a potential Unintentional ThreadLocal Leak (UTL) in `ThreadLocalStatisticsCollector`. The class relies on consumers manually calling `resetThread()` at \"request boundaries\" to clear the `ThreadLocal\u003cSimpleStatisticsCollector>`. \n\nHowever, in typical GraphQL environments (reactive streams, async gateways, or standard thread pools), threads are heavily reused. If an unhandled exception occurs or a developer forgets to call `resetThread()`, the `SimpleStatisticsCollector` object is permanently retained by the worker thread. \n\n**Impact:**\n1. **Data Pollution:** Subsequent requests processed by the dirty thread will inherit the accumulated statistics of previous requests, leading to completely distorted metrics.\n2. **Memory Leak (Type I UTL):** As more threads in the pool retain these un-cleared statistics objects over time, the heap usage will grow linearly, potentially leading to an `OutOfMemoryError` in high-throughput applications.\n\n**To Reproduce**\nHere is a simplified code example demonstrating the data pollution in a thread-pool environment when `resetThread()` is missed (e.g., bypassed due to an exception):\n\n```java\nimport org.dataloader.stats.ThreadLocalStatisticsCollector;\nimport java.util.concurrent.*;\n\npublic class UTLReproduction {\n public static void main(String[] args) throws Exception {\n ThreadLocalStatisticsCollector collector = new ThreadLocalStatisticsCollector();\n // Simulate a web server with a reusable thread pool\n ExecutorService threadPool = Executors.newFixedThreadPool(1);\n\n // Request 1: Execution completes but resetThread() is missed (e.g. exception thrown)\n threadPool.submit(() -> {\n collector.incrementLoadCount();\n // Developer forgets to put collector.resetThread() in a finally block\n }).get();\n\n // Request 2: A new incoming request reuses the same dirty thread\n threadPool.submit(() -> {\n long loadCount = collector.getStatistics().getLoadCount();\n // BUG: loadCount is 1 instead of 0! The new request is polluted by Request 1.\n System.out.println(\"New Request Load Count (Expected 0): \" + loadCount);\n }).get();\n \n threadPool.shutdown();\n }\n}","author":{"url":"https://github.com/QiuYucheng2003","@type":"Person","name":"QiuYucheng2003"},"datePublished":"2026-02-22T06:10:06Z","url":"https://github.com/graphql-java/java-dataloader/issues/266"}
react-profiling 0 react-import-map react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 route-pattern /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) route-controller voltron_issues_fragments route-action issue_layout fetch-nonce v2:620218b9-0f9a-efaf-6b41-61778e64b10e current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id B76A:399E4B:21ADBBC:2CA40F7:6B017E6C html-safe-nonce 6ec0627b65ff5f395c865a83dc36035ea3f7ad30f713408097b8bf7e2e3ae509 visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzZBOjM5OUU0QjoyMUFEQkJDOjJDQTQwRjc6NkIwMTdFNkMiLCJ2aXNpdG9yX2lkIjoiNjUyNjU3NDg5NzI0MTQ1MjYwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= visitor-hmac c4c882cd28094162e7c78b98404858181ea31d142ff78e6dfbf3c2fef6151213 hovercard-subject-tag issue:3973697074 github-keyboard-shortcuts repository,issues,copilot google-site-verification Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I octolytics-url https://collector.github.com/github/collect analytics-location / fb:app_id 1401488693436528 apple-itunes-app app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/graphql-java/java-dataloader/266/issue_layout twitter:image https://opengraph.githubassets.com/72d101361f4acd4a24feca5ecb63705da58b22747949ba50eee9bdcd380fa1bc/graphql-java/java-dataloader/issues/266 twitter:card summary_large_image og:image https://opengraph.githubassets.com/72d101361f4acd4a24feca5ecb63705da58b22747949ba50eee9bdcd380fa1bc/graphql-java/java-dataloader/issues/266 og:image:alt Describe the bug There is a potential Unintentional ThreadLocal Leak (UTL) in ThreadLocalStatisticsCollector. The class relies on consumers manually calling resetThread() at "request boundaries" to... og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username QiuYucheng2003 hostname github.com expected-hostname github.com None cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c turbo-cache-control no-preview go-import github.com/graphql-java/java-dataloader git https://github.com/graphql-java/java-dataloader.git octolytics-dimension-user_id 14289921 octolytics-dimension-user_login graphql-java octolytics-dimension-repository_id 97364654 octolytics-dimension-repository_nwo graphql-java/java-dataloader octolytics-dimension-repository_public true octolytics-dimension-repository_is_fork false octolytics-dimension-repository_network_root_id 97364654 octolytics-dimension-repository_network_root_nwo graphql-java/java-dataloader turbo-body-classes logged-out env-production page-responsive disable-turbo false browser-stats-url https://api.github.com/_private/browser/stats browser-errors-url https://api.github.com/_private/browser/errors release 8c77c9e8439031ad54c75a250694842892f693e1 ui-target full theme-color #1e2327 color-scheme light dark react-app-name issues
URLs of crawlers that visited me.