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

  1. Null-check the key before calling unregister, or skip the call entirely when absent.
  2. Ensure configuration loading always populates the loader key used at teardown.
  3. 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

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


AI-assisted analysis of Konloch/bytecode-viewer@31430e0033 (2026-09-05). Data as JSON: /api/errors/ee1289615388186e. Report an issue: GitHub.