{"record":{"id":"82b510e8339e87c7","repo":"apache/maven","slug":"extensioncontext-must-not-be-null","errorCode":null,"errorMessage":"ExtensionContext must not be null","messagePattern":"ExtensionContext must not be null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java","lineNumber":103,"sourceCode":"    /**\n     * Retrieves the extension context for the current thread.\n     *\n     * @return The extension context, or an empty Optional if not set\n     */\n    protected static Optional<ExtensionContext> getContext() {\n        return Optional.ofNullable(EXTENSION_CONTEXT_THREAD_LOCAL.get());\n    }\n\n    /**\n     * Creates and configures the DI container for test execution.\n     * Performs component discovery and sets up basic bindings.\n     *\n     * @throws IllegalStateException if the ExtensionContext is null, the required test class is unavailable,\n     *         the required test instance is unavailable, or if container setup fails\n     */\n    protected Injector setupContainer(ExtensionContext context) {\n        if (context == null) {\n            throw new IllegalStateException(\"ExtensionContext must not be null\");\n        }\n        final Class<?> testClass = context.getRequiredTestClass();\n        if (testClass == null) {\n            throw new IllegalStateException(\"Required test class is not available in ExtensionContext\");\n        }\n        final Object testInstance = context.getRequiredTestInstance();\n        if (testInstance == null) {\n            throw new IllegalStateException(\"Required test instance is not available in ExtensionContext\");\n        }\n\n        try {\n            Injector injector = Injector.create();\n            injector.bindInstance(ExtensionContext.class, context);\n            injector.discover(testClass.getClassLoader());\n            injector.bindInstance(Injector.class, injector);\n            injector.bindInstance(testClass.asSubclass(Object.class), (Object) testInstance); // Safe generics handling\n            return injector;\n        } catch (final Exception e) {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java#L85-L121","documentation":"Error \"ExtensionContext must not be null\" thrown in apache/maven.","triggerScenarios":"Thrown at impl/maven-testing/src/main/java/org/apache/maven/testing/di/MavenDIExtension.java:103 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}