From a0d91715eab8df73db4d9aa227fd126152b6a043 Mon Sep 17 00:00:00 2001 From: duncanmcqueen Date: Wed, 14 Oct 2026 08:26:59 -0500 Subject: [PATCH] ResolverCache: make the cache before the TTLs 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 Signed-off-by: duncanmcqueen --- java/net/ResolverCache.java | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/java/net/ResolverCache.java b/java/net/ResolverCache.java index d7e5ed407b..75e3ccd9eb 100644 --- a/java/net/ResolverCache.java +++ b/java/net/ResolverCache.java @@ -70,6 +70,19 @@ */ class ResolverCache { + /** + * The cache itself. It is declared before the TTLs: computing them can + * load classes that resolve names, and the cache must exist by then. + * Lookups made during that time see both TTLs as 0, so their results + * are not cached. + */ + private static HashMap cache = new HashMap(); + + /** + * List of entries which may expire. + */ + private static LinkedList killqueue = new LinkedList(); + /** * The time in seconds for which successful lookups are cached. */ @@ -94,16 +107,6 @@ private static int getTTL(String propName, int defaultValue) return Integer.parseInt(propValue); } - /** - * The cache itself. - */ - private static HashMap cache = new HashMap(); - - /** - * List of entries which may expire. - */ - private static LinkedList killqueue = new LinkedList(); - /** * Return the hostname for the specified IP address. *