{"record":{"id":"4bc78a6839f69a8e","repo":"jhy/jsoup","slug":"not-yet-executed","errorCode":null,"errorMessage":"Not yet executed","messagePattern":"Not yet executed","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/jsoup/helper/UrlConnectionExecutor.java","lineNumber":66,"sourceCode":"            res.url = conn.getURL();\n            res.statusCode = conn.getResponseCode();\n            res.statusMessage = conn.getResponseMessage();\n            if (res.statusMessage == null) res.statusMessage = \"\"; // getResponseMessage may be null but statusMessage() is not null\n            res.contentType = conn.getContentType();\n            res.contentLength = conn.getContentLength();\n            Map<String, List<String>> resHeaders = createHeaderMap(conn);\n            res.prepareResponse(resHeaders, prevRes);\n\n            return res;\n        } catch (IOException e) {\n            safeClose();\n            throw e;\n        }\n    }\n\n    @Override\n    InputStream responseBody() throws IOException {\n        if (conn == null) throw new IllegalStateException(\"Not yet executed\");\n        return conn.getErrorStream() != null ? conn.getErrorStream() : conn.getInputStream();\n    }\n\n    @Override\n    void safeClose() {\n        if (conn != null) {\n            conn.disconnect();\n            conn = null;\n        }\n    }\n\n    // set up connection defaults, and details from request\n    private static HttpURLConnection createConnection(HttpConnection.Request req) throws IOException {\n        Proxy proxy = req.proxy();\n        final HttpURLConnection conn = (HttpURLConnection) (\n            proxy == null ?\n                req.url().openConnection() :\n                req.url().openConnection(proxy)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/jhy/jsoup/blob/9851ac5d9c576c6888910b5a51a2362bbc978959/src/main/java/org/jsoup/helper/UrlConnectionExecutor.java#L48-L84","documentation":"UrlConnectionExecutor.responseBody() requires that execute() has already been called and produced a live HttpURLConnection. If the internal conn reference is still null, the executor is in an invalid state and an IllegalStateException is thrown instead of attempting IO.","triggerScenarios":"Calling responseBody() directly on a newly constructed UrlConnectionExecutor without invoking execute() first; calling it after safeClose() reset the connection; reusing a single executor for a second response read after it was torn down.","commonSituations":"Custom request pipelines that bypass the normal jsoup Connection API and read the body out of order; code refactors where execute() moved behind a conditional branch that silently skipped it.","solutions":["Call execute() before requesting the response body","Use the high-level jsoup Connection API (Jsoup.connect(...).execute()) so ordering is enforced","Create a fresh executor per request instead of reusing a closed one"],"exampleFix":"// before\nConnection.Response res = executor.responseBody(); // conn == null\n// after\nexecutor.execute();\nInputStream body = executor.responseBody();","handlingStrategy":"type-guard","validationCode":"if (executor == null || !executor.hasExecuted()) { // track via execute() return/flag\n    throw new IllegalStateException(\"Must call execute() before reading the body\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    InputStream body = executor.responseBody();\n} catch (IllegalStateException e) {\n    executor.execute(); // recover by completing the lifecycle\n    body = executor.responseBody();\n}","preventionTips":["Always call execute() before responseBody(); prefer the high-level Connection API which enforces ordering","Treat the executor as single-use; create a new one per request","Do not read the body after safeClose()"],"tags":["lifecycle","http","illegal-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"9851ac5d9c576c6888910b5a51a2362bbc978959","analyzedAt":"2026-09-08T15:22:04.931Z","contentChangedAt":"2026-09-08T15:22:04.931Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}