Konloch/bytecode-viewer · error · IllegalArgumentException
null key
Error message
null key
What it means
Thrown by AbstractLoaderFactory.unregister when the key argument is null. The unregister path first validates that a key was supplied before consulting the cache, failing fast with a clear message instead of an opaque NullPointerException.
Source
Thrown at src/main/java/the/bytecode/club/bytecodeviewer/bootloader/loader/AbstractLoaderFactory.java:60
{
if (key == null || factory == null)
{
throw new IllegalArgumentException("null key or factory");
}
if (FACTORY_CACHE.containsKey(key))
{
throw new IllegalArgumentException("factory already registered with key: " + key);
}
FACTORY_CACHE.put(key, factory);
}
public static void unregister(String key)
{
if (key == null)
{
throw new IllegalArgumentException("null key");
}
if (!FACTORY_CACHE.containsKey(key))
{
throw new IllegalArgumentException("factory doesn't key for key: " + key);
}
FACTORY_CACHE.remove(key);
}
public static <T extends ExternalResource<?>> LoaderFactory<T> find()
{
return find(DEFAULT_KEY);
}
@SuppressWarnings("unchecked")
public static <T extends ExternalResource<?>> LoaderFactory<T> find(String key)
{View on GitHub (pinned to 31430e0033)
Solutions
- Null-check the key before calling unregister, or skip the call entirely when absent.
- Ensure configuration loading always populates the loader key used at teardown.
- Track registered keys (a Set) at registration time and iterate those at cleanup instead of config values.
Example fix
// before unregister(config.getLoaderKey()); // after String key = config.getLoaderKey(); if (key != null) unregister(key);
Defensive patterns
Strategy: validation
Validate before calling
if (key != null) AbstractLoaderFactory.unregister(key);
Type guard
boolean canUnregister(String key) { return key != null; } Try / catch
try { AbstractLoaderFactory.unregister(key); }
catch (IllegalArgumentException e) {
if ("null key".equals(e.getMessage())) log.warn("skipping teardown: no loader key configured");
else throw e;
} Prevention
- Track your own set of registered keys at registration time for cleanup
- Null-check config values used in shutdown hooks
- Fail fast at config-load time so missing keys never reach teardown
When it happens
Trigger: Calling AbstractLoaderFactory.unregister(null), e.g. a cleanup/shutdown hook that derives the key from a variable that was never set, or config-driven teardown where the loader name is missing.
Common situations: Shutdown code iterating over configured loaders where some entries are blank; refactors where the key constant was renamed and one call site still passes an uninitialized field.
Related errors
- null key or factory
- factory already registered with key: ${key}
- factory doesn't key for key: ${key}
- '${codebase}' is not a directory
- Unknown constant pool tag ${tag}
AI-assisted analysis of Konloch/bytecode-viewer@31430e0033 (2026-09-05).
Data as JSON: /api/errors/ee1289615388186e.
Report an issue: GitHub.