Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yuanbw opened this issue Aug 25, 2022 · 0 comments

Comments

@yuanbw
Copy link

yuanbw commented Aug 25, 2022

@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 {
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant