René's URL Explorer Experiment


Title: NioClient.close() sometimes leaves the shutdown hook registered · Issue #435 · dnsjava/dnsjava · GitHub

Open Graph Title: NioClient.close() sometimes leaves the shutdown hook registered · Issue #435 · dnsjava/dnsjava

X Title: NioClient.close() sometimes leaves the shutdown hook registered · Issue #435 · dnsjava/dnsjava

Description: Version 3.7.1 (also 3.6.5; master is unchanged) Description NioClient.close() sets run = false, wakes up the selector, and only afterwards removes the shutdown hook: synchronized (NIO_CLIENT_LOCK) { run = false; localSelector = selector;...

Open Graph Description: Version 3.7.1 (also 3.6.5; master is unchanged) Description NioClient.close() sets run = false, wakes up the selector, and only afterwards removes the shutdown hook: synchronized (NIO_CLIENT_LOCK) ...

X Description: Version 3.7.1 (also 3.6.5; master is unchanged) Description NioClient.close() sets run = false, wakes up the selector, and only afterwards removes the shutdown hook: synchronized (NIO_CLIENT_LOCK) ...

Opengraph URL: https://github.com/dnsjava/dnsjava/issues/435

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NioClient.close() sometimes leaves the shutdown hook registered","articleBody":"## Version\n\n3.7.1 (also 3.6.5; `master` is unchanged)\n\n## Description\n\n`NioClient.close()` sets `run = false`, wakes up the selector, and only afterwards removes the shutdown hook:\n\n```java\nsynchronized (NIO_CLIENT_LOCK) {\n  run = false;\n  localSelector = selector;\n  localSelectorThread = selectorThread;\n}\nif (localSelector != null) {\n  localSelector.wakeup();\n}\nif (!fromHook) {\n  synchronized (NIO_CLIENT_LOCK) {\n    if (closeThread != null) {\n      Runtime.getRuntime().removeShutdownHook(closeThread);\n      ...\n```\n\nIn between, the selector thread can leave its loop and run `cleanupAfterRun()`, which sets `closeThread = null`.\n`close()` then finds `closeThread == null` and doesn't remove the hook, so it stays registered until the JVM exits.\n\nIn a servlet container this leaks the web application: the hook thread's context class loader is the webapp's,\nso the webapp can't be unloaded after it was stopped, although `close()` was called on undeploy. This is the\nuse case of #180, which added `close()` for a clean shutdown inside Tomcat: since the self-join mentioned there\nwas fixed in 3.7.0, the selector thread stops, but the hook still keeps the webapp loaded now and then. Our\nnightly webapp leak check hit it once in about 50 runs.\n\n## Reproduction\n\nStart the client and close it in a loop, checking whether the hook is still registered afterwards. With busy\nthreads on all cores to make the closing thread lose the CPU after `wakeup()`, we got 6 leaked hooks in 2,000\niterations on a 12-core machine:\n\n```java\nField field = NioClient.class.getDeclaredField(\"closeThread\");\nfield.setAccessible(true);\nSimpleResolver resolver = new SimpleResolver(new InetSocketAddress(\"127.0.0.1\", 9));\nMessage query = Message.newQuery(Record.newRecord(Name.fromString(\"example.com.\"), Type.A, DClass.IN));\nfor (int i = 0; i \u003c 2000; i++) {\n  resolver.sendAsync(query);\n  Thread hook = (Thread) field.get(null);\n  NioClient.close();\n  if (Runtime.getRuntime().removeShutdownHook(hook)) {\n    System.out.println(\"hook still registered after close()\");\n  }\n}\n```\n\n## Suggested fix\n\nRead `closeThread` in the first synchronized block together with `selector` and `selectorThread`, and remove\nthat hook, or remove the hook in the same block that sets `run = false`.","author":{"url":"https://github.com/stbstb","@type":"Person","name":"stbstb"},"datePublished":"2026-11-16T09:36:15Z","url":"https://github.com/dnsjava/dnsjava/issues/435"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:06c4f7fc-7aeb-d247-4beb-240acb9274f5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA6FE:3C2607:83CF91:AA273E:6B062BBD
html-safe-noncec67ee00feadd8c43cfa3561a0c09eef9b8a0bc6e56fe7a085c2ca40c96dbca64
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkZFOjNDMjYwNzo4M0NGOTE6QUEyNzNFOjZCMDYyQkJEIiwidmlzaXRvcl9pZCI6IjYwMzY0NzQ1MjIyNjAzNTE5MzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1186e4c992569268c769a1af47656ad4bf2591ce6fdf435ce0257fecd5e68b7c
hovercard-subject-tagissue:6418352443
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/dnsjava/dnsjava/435/issue_layout
twitter:imagehttps://opengraph.githubassets.com/fc0fbe1c6f1f860d6ca5c334c61b66539a4d8aeb8a2a347fc3971bf82d640db8/dnsjava/dnsjava/issues/435
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/fc0fbe1c6f1f860d6ca5c334c61b66539a4d8aeb8a2a347fc3971bf82d640db8/dnsjava/dnsjava/issues/435
og:image:altVersion 3.7.1 (also 3.6.5; master is unchanged) Description NioClient.close() sets run = false, wakes up the selector, and only afterwards removes the shutdown hook: synchronized (NIO_CLIENT_LOCK) ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamestbstb
hostnamegithub.com
expected-hostnamegithub.com
None7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3
turbo-cache-controlno-preview
go-importgithub.com/dnsjava/dnsjava git https://github.com/dnsjava/dnsjava.git
octolytics-dimension-user_id6755615
octolytics-dimension-user_logindnsjava
octolytics-dimension-repository_id17084567
octolytics-dimension-repository_nwodnsjava/dnsjava
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id17084567
octolytics-dimension-repository_network_root_nwodnsjava/dnsjava
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release494ea0bb1e0feef734a83e2628697647755e8864
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/dnsjava/dnsjava/issues/435#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdnsjava%2Fdnsjava%2Fissues%2F435
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdnsjava%2Fdnsjava%2Fissues%2F435
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=dnsjava%2Fdnsjava
Reloadhttps://github.com/dnsjava/dnsjava/issues/435
Reloadhttps://github.com/dnsjava/dnsjava/issues/435
Reloadhttps://github.com/dnsjava/dnsjava/issues/435
dnsjavahttps://github.com/dnsjava
dnsjavahttps://github.com/dnsjava/dnsjava
Codehttps://github.com/dnsjava/dnsjava
Issues16 (16)https://github.com/dnsjava/dnsjava/issues
Pull requests3 (3)https://github.com/dnsjava/dnsjava/pulls
Actionshttps://github.com/dnsjava/dnsjava/actions
Security and quality8 (8)https://github.com/dnsjava/dnsjava/security
Insightshttps://github.com/dnsjava/dnsjava/insights
https://github.com/dnsjava/dnsjava
New issuehttps://github.com/login?return_to=https://github.com/dnsjava/dnsjava/issues/435
New issuehttps://github.com/login?return_to=https://github.com/dnsjava/dnsjava/issues/435
NioClient.close() sometimes leaves the shutdown hook registeredhttps://github.com/dnsjava/dnsjava/issues/435#top
bughttps://github.com/dnsjava/dnsjava/issues?q=state%3Aopen%20label%3A%22bug%22
3.7.2https://github.com/dnsjava/dnsjava/milestone/25
https://github.com/stbstb
stbstbhttps://github.com/stbstb
on Nov 16, 2026https://github.com/dnsjava/dnsjava/issues/435#issue-6418352443
#180https://github.com/dnsjava/dnsjava/issues/180
ibauersachshttps://github.com/ibauersachs
completedhttps://github.com/dnsjava/dnsjava/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
ab9f492https://github.com/dnsjava/dnsjava/commit/ab9f492329e15bf53771b9dababc52a3fdb7f481
on Nov 21, 2026https://github.com/dnsjava/dnsjava/issues/435#event-36861653279
ibauersachshttps://github.com/ibauersachs
3.7.2https://github.com/dnsjava/dnsjava/milestone/25
on Nov 21, 2026https://github.com/dnsjava/dnsjava/issues/435#event-36861674283
ibauersachshttps://github.com/ibauersachs
bughttps://github.com/dnsjava/dnsjava/issues?q=state%3Aopen%20label%3A%22bug%22
on Nov 21, 2026https://github.com/dnsjava/dnsjava/issues/435#event-36861677143
sean-g-raehttps://github.com/sean-g-rae
on Nov 23, 2026https://github.com/dnsjava/dnsjava/issues/435#event-36958776144
Remove the NIO shutdown hook before waking up the selector (dnsjava#438)https://github.com/sean-g-rae/dnsjava/commit/ab9f492329e15bf53771b9dababc52a3fdb7f481
dnsjava#438https://github.com/dnsjava/dnsjava/pull/438
https://docs.github.com/articles/closing-issues-via-commit-messages
ab9f492https://github.com/sean-g-rae/dnsjava/commit/ab9f492329e15bf53771b9dababc52a3fdb7f481
Sign up for freehttps://github.com/signup?return_to=https://github.com/dnsjava/dnsjava/issues/435
Sign in to commenthttps://github.com/login?return_to=https://github.com/dnsjava/dnsjava/issues/435
bughttps://github.com/dnsjava/dnsjava/issues?q=state%3Aopen%20label%3A%22bug%22
3.7.2No due datehttps://github.com/dnsjava/dnsjava/milestone/25
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.