Skip to content

HttpAdapter getResponse return null, and HttpAdapter is duplicated with HttpAdapterByHeader #155

@yuanbw

Description

@yuanbw

@wufan1991

Symptom

In the getResponse function from https://github.com/FederatedAI/FATE-Serving/blob/master/fate-serving-common/src/main/java/com/webank/ai/fate/serving/common/utils/HttpAdapterClientPool.java,
private static HttpAdapterResponse getResponse(HttpRequestBase request) {
CloseableHttpResponse response = null;
try {
response = HttpClientPool.getConnection().execute(request,
HttpClientContext.create());
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity, Dict.CHARSET_UTF8);
return JsonUtil.json2Object(result, HttpAdapterResponse.class); <--will always return null,
}
...
}
JsonUtil.json2Object(result, HttpAdapterResponse.class) will always return null, because the result is not an HttpAdapterResponse object.

solution

1.update getResponse fucntion like this.
2.rename HttpAdapterByHeader class to HttpAdapter, these two classes are duplicated.
try {
...
String data = EntityUtils.toString(entity, Dict.CHARSET_UTF8);
int statusCode = response.getStatusLine().getStatusCode();
HttpAdapterResponse result = new HttpAdapterResponse();
result.setCode(statusCode);
result.setData(JsonUtil.json2Object(data,Map.class)); #data is only an Map<String,Object> object in HttpAdapterResponse
return result;
} catch (IOException ex) {
...
} finally {
...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions