{"record":{"id":"0508465a80438872","repo":"alibaba/DataX","slug":"response-entity-is-null","errorCode":null,"errorMessage":"Response Entity Is Null","messagePattern":"Response Entity Is Null","errorType":"http","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/datax/core/util/HttpClientUtil.java","lineNumber":131,"sourceCode":"    public String executeAndGet(HttpRequestBase httpRequestBase) throws Exception {\n        HttpResponse response;\n        String entiStr = \"\";\n        try {\n            response = httpClient.execute(httpRequestBase);\n\n            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {\n                System.err.println(\"请求地址：\" + httpRequestBase.getURI() + \", 请求方法：\" + httpRequestBase.getMethod()\n                        + \",STATUS CODE = \" + response.getStatusLine().getStatusCode());\n                if (httpRequestBase != null) {\n                    httpRequestBase.abort();\n                }\n                throw new Exception(\"Response Status Code : \" + response.getStatusLine().getStatusCode());\n            } else {\n                HttpEntity entity = response.getEntity();\n                if (entity != null) {\n                    entiStr = EntityUtils.toString(entity, Consts.UTF_8);\n                } else {\n                    throw new Exception(\"Response Entity Is Null\");\n                }\n            }\n        } catch (Exception e) {\n            throw e;\n        }\n\n        return entiStr;\n    }\n\n    public String executeAndGetWithRetry(final HttpRequestBase httpRequestBase, final int retryTimes, final long retryInterval) {\n        try {\n            return RetryUtil.asyncExecuteWithRetry(new Callable<String>() {\n                @Override\n                public String call() throws Exception {\n                    return executeAndGet(httpRequestBase);\n                }\n            }, retryTimes, retryInterval, true, HTTP_TIMEOUT_INMILLIONSECONDS + 1000, asyncExecutor);\n        } catch (Exception e) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/core/src/main/java/com/alibaba/datax/core/util/HttpClientUtil.java#L113-L149","documentation":"HttpClientUtil.executeAndGet throws this when the server returns status 200 but the response entity is null, so there is no body to convert to a String. It is the companion check to the status-code check: the request 'succeeded' but carried no payload, which this utility treats as an error because callers expect a body.","triggerScenarios":"A HEAD-like or empty 200 response from the endpoint, a server that acknowledges with no body, or a connection reset after headers are received so the entity stream is absent. Only occurs when status == 200 and response.getEntity() returns null.","commonSituations":"Health-check or ack endpoints that return bare 200s, intermediate proxies that strip bodies, or version drift where an endpoint stopped returning content. Rare compared to the status-code error but hits the same call sites.","solutions":["Confirm with curl -i whether the endpoint really returns an empty body on success.","If an empty 200 is valid for your flow, stop using executeAndGet for that call and use a path that tolerates a null entity.","Check for proxies/gateways between DataX and the service that may drop response bodies.","Verify the endpoint path and Accept headers match the API version the server implements."],"exampleFix":"// before\nString body = httpClientUtil.executeAndGet(get); // throws on empty 200\n// after\nHttpResponse resp = httpClient.execute(get);\nHttpEntity e = resp.getEntity();\nString body = (e == null) ? \"\" : EntityUtils.toString(e, Consts.UTF_8);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { body = httpClientUtil.executeAndGet(req); } catch (Exception e) { if (\"Response Entity Is Null\".equals(e.getMessage())) { body = \"\"; /* 200 with no body: acceptable for ack endpoints */ } else throw e; }","preventionTips":["Know which endpoints return empty 200s and do not route them through executeAndGet.","Regression-test integrations against the actual server version, not stubs, to catch body-less responses early."],"tags":["datax","http","rest-client","empty-response"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}