Repository navigation
ResolverCache: make the cache before the TTLs - #64
Open
duncanmcqueen wants to merge 1 commit into
Open
duncanmcqueen wants to merge 1 commit into
duncanmcqueen wants to merge 1 commit into
Conversation
The static initializer computed POSITIVE_TTL and NEGATIVE_TTL first. Reading the security properties for them can resolve a host name, which uses the cache before it exists (NullPointerException). Declare the cache and the kill queue first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com>
This was referenced Oct 14, 2026
duncanmcqueen
marked this pull request as ready for review
October 14, 2026 23:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #59.
Problem and fix
The static initializer of
java.net.ResolverCachesetsPOSITIVE_TTLandNEGATIVE_TTLbeforecache. To get the TTLs, it callsSecurity.getProperty(). This can initializejava.security.Security, which reads its provider file from thegnu.classpath.home.urlURL.If that URL is not a local file,
Securityopens a network connection. The connection resolves a host name withResolverCache.getHostByName().ResolverCacheis not fully initialized yet, socacheisnull:ResolverCache.get()throwsNullPointerException.InetSocketAddresscatches all exceptions and makes an unresolved address.Socket.connect()throwsUnresolvedAddressException.Security.loadProviders()does not catch this exception.Security,ResolverCacheandInetAddressfails withExceptionInInitializerError. After that, no network operation works.This change declares
cacheandkillqueuebefore the TTLs.How to reproduce
The test sets
gnu.classpath.home.urlto an HTTP URL and then resolves a host name. Run it as the first program in the VM (nothing must initializeSecurityorInetAddressbefore).ResolverCacheInit.javaResults
Linux x86_64, ingelabs/classpath
master(0406074), JamVMmaster,javacfrom JDK 8, autoconf 2.73, automake 1.19, theconfigureoptions of the CI Linux job, out-of-tree build. "Before" ismaster. "After" ismasterwith this commit.I first found the problem with Kaffe on Haiku.
Platforms
Not specific to Haiku. The problem occurs on all systems and VMs when
gnu.classpath.home.urlis not a local file. I reproduced it on Linux with JamVM.AI assistance
An AI model (Claude Code, by Anthropic) wrote this change, the test and this text. The repository owner directed the work and checked the results. Please review it as you review other contributions.
🤖 Generated with Claude Code