我通过Java客户端发出一个多获取请求,并收到以下异常:
无法解析响应体(requestLine=POST /_mget HTTP/1.1,host=http://localhost:9200,response=HTTP/1.1 200 OK})
我从发送给Elastic的日志中提取了以下JSON:
{
"docs": [
{
"_index": "blah",
"_type": null,
"_id": "some-id-232332",
"routing": null,
"stored_fields": null,
"version": -3,
"version_type": "internal",
"_source": {
"includes": [],
"excludes": []
}
}
]
}我通过Postman将上面的JSON发送给Elastic,我看到了以下响应(这与我在日志中看到的相同):
{
"docs": [
{
"_index": "blah",
"_type": null,
"_id": "some-id-232332",
"found": false
}
]
}这不是一个有效的答复吗?这是一个问题吗?elasticsearch-rest-高级客户端?
弹性7.5.0,org.elasticsearch.client:elasticsearch-rest-high-level-client:7.5.2
发布于 2020-03-06 15:21:05
我需要检查getCause()的例外情况,看看真正的问题。我在mapper.readValue(nullBytes, Customer.class);上把null传给杰克逊,这才是真正的问题。
有趣的是,NPE显示自己为♂️。
堆栈跟踪: java.util.concurrent.ExecutionException: java.io.IOException:无法为响应解析响应正文{requestLine=POST /_mget HTTP/1.1,host=http://localhost:9200,response=HTTP/1.1 200 OK} ..。 ..。 真正的问题就在这里! 由: com.fasterxml.jackson.databind.ObjectMapper._assertNotNull(ObjectMapper.java:4429)的java.lang.IllegalArgumentException:参数"src“为空
restHighLevelClient.mgetAsync(multiGetRequest, RequestOptions.DEFAULT, new ActionListener<MultiGetResponse>() {
@Override
public void onResponse(MultiGetResponse response) {
for (var responseItem : response.getResponses()) {
try {
// simulating a null source
byte[] nullBytes = null;
customer = mapper.readValue(nullBytes, Customer.class);
} catch (IOException e) {
result.completeExceptionally(e);
}
}
result.complete(true);
}
@Override
public void onFailure(Exception ex) {
//the real problem!!!
//log.error("ex.cause", ex.getCause());
log.error("error with mget", ex);
result.completeExceptionally(ex);
}
});https://stackoverflow.com/questions/60537642
复制相似问题