alibaba/DataX · error · Exception

Response Entity Is Null

Error message

Response Entity Is Null

What it means

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.

Source

Thrown at core/src/main/java/com/alibaba/datax/core/util/HttpClientUtil.java:131

    public String executeAndGet(HttpRequestBase httpRequestBase) throws Exception {
        HttpResponse response;
        String entiStr = "";
        try {
            response = httpClient.execute(httpRequestBase);

            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
                System.err.println("请求地址:" + httpRequestBase.getURI() + ", 请求方法:" + httpRequestBase.getMethod()
                        + ",STATUS CODE = " + response.getStatusLine().getStatusCode());
                if (httpRequestBase != null) {
                    httpRequestBase.abort();
                }
                throw new Exception("Response Status Code : " + response.getStatusLine().getStatusCode());
            } else {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    entiStr = EntityUtils.toString(entity, Consts.UTF_8);
                } else {
                    throw new Exception("Response Entity Is Null");
                }
            }
        } catch (Exception e) {
            throw e;
        }

        return entiStr;
    }

    public String executeAndGetWithRetry(final HttpRequestBase httpRequestBase, final int retryTimes, final long retryInterval) {
        try {
            return RetryUtil.asyncExecuteWithRetry(new Callable<String>() {
                @Override
                public String call() throws Exception {
                    return executeAndGet(httpRequestBase);
                }
            }, retryTimes, retryInterval, true, HTTP_TIMEOUT_INMILLIONSECONDS + 1000, asyncExecutor);
        } catch (Exception e) {

View on GitHub (pinned to 80ec23d5c5)

Solutions

  1. Confirm with curl -i whether the endpoint really returns an empty body on success.
  2. If an empty 200 is valid for your flow, stop using executeAndGet for that call and use a path that tolerates a null entity.
  3. Check for proxies/gateways between DataX and the service that may drop response bodies.
  4. Verify the endpoint path and Accept headers match the API version the server implements.

Example fix

// before
String body = httpClientUtil.executeAndGet(get); // throws on empty 200
// after
HttpResponse resp = httpClient.execute(get);
HttpEntity e = resp.getEntity();
String body = (e == null) ? "" : EntityUtils.toString(e, Consts.UTF_8);
Defensive patterns

Strategy: try-catch

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14). Data as JSON: /api/errors/0508465a80438872. Report an issue: GitHub.