-
Notifications
You must be signed in to change notification settings - Fork 77
Description
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 {
...
}