{"record":{"id":"ee1289615388186e","repo":"Konloch/bytecode-viewer","slug":"null-key","errorCode":null,"errorMessage":"null key","messagePattern":"null key","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/the/bytecode/club/bytecodeviewer/bootloader/loader/AbstractLoaderFactory.java","lineNumber":60,"sourceCode":"    {\n        if (key == null || factory == null)\n        {\n            throw new IllegalArgumentException(\"null key or factory\");\n        }\n\n        if (FACTORY_CACHE.containsKey(key))\n        {\n            throw new IllegalArgumentException(\"factory already registered with key: \" + key);\n        }\n\n        FACTORY_CACHE.put(key, factory);\n    }\n\n    public static void unregister(String key)\n    {\n        if (key == null)\n        {\n            throw new IllegalArgumentException(\"null key\");\n        }\n\n        if (!FACTORY_CACHE.containsKey(key))\n        {\n            throw new IllegalArgumentException(\"factory doesn't key for key: \" + key);\n        }\n\n        FACTORY_CACHE.remove(key);\n    }\n\n    public static <T extends ExternalResource<?>> LoaderFactory<T> find()\n    {\n        return find(DEFAULT_KEY);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public static <T extends ExternalResource<?>> LoaderFactory<T> find(String key)\n    {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Konloch/bytecode-viewer/blob/31430e0033fa220db566b5ef461256727ff6793b/src/main/java/the/bytecode/club/bytecodeviewer/bootloader/loader/AbstractLoaderFactory.java#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nunregister(config.getLoaderKey());\n// after\nString key = config.getLoaderKey();\nif (key != null) unregister(key);","handlingStrategy":"validation","validationCode":"if (key != null) AbstractLoaderFactory.unregister(key);","typeGuard":"boolean canUnregister(String key) { return key != null; }","tryCatchPattern":"try { AbstractLoaderFactory.unregister(key); }\ncatch (IllegalArgumentException e) {\n    if (\"null key\".equals(e.getMessage())) log.warn(\"skipping teardown: no loader key configured\");\n    else throw e;\n}","preventionTips":["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"],"tags":["java","loader","registry","null-check"],"backgroundTag":"null-argument-validation","analyzedSha":"31430e0033fa220db566b5ef461256727ff6793b","analyzedAt":"2026-09-05T18:22:22.725Z","contentChangedAt":"2026-09-05T18:22:22.725Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}