use of org.apache.commons.httpclient.NoHttpResponseException in project zm-mailbox by Zimbra.
the class ElasticSearchConnector method executeMethod.
public int executeMethod(HttpMethod method) throws IndexStoreException, IOException {
String reqBody = "";
if (ZimbraLog.elasticsearch.isTraceEnabled() && method instanceof EntityEnclosingMethod) {
EntityEnclosingMethod eem = (EntityEnclosingMethod) method;
RequestEntity re = eem.getRequestEntity();
if (re instanceof StringRequestEntity) {
StringRequestEntity sre = (StringRequestEntity) re;
reqBody = Strings.nullToEmpty(sre.getContent());
if (reqBody.length() > 0) {
reqBody = String.format("\nREQUEST BODY=%s", reqBody);
}
}
}
try {
HttpClient client = ZimbraHttpConnectionManager.getInternalHttpConnMgr().newHttpClient();
statusCode = client.executeMethod(method);
} catch (ConnectException ce) {
throw new ZimbraElasticSearchDownException(ce);
} catch (NoHttpResponseException nhre) {
// them after retrying a number of times.
throw new ZimbraElasticSearchNoResponseException(nhre);
}
body = method.getResponseBodyAsString();
ZimbraLog.elasticsearch.trace("ElasticSearch request:%s %s - statusCode=%d%s\nRESPONSE BODY=%s", method.getName(), method.getURI(), statusCode, reqBody, body);
return statusCode;
}
Aggregations