Remove RestClient#JSON_CONTENT_TYPE constant, already available in ContentType class

This commit is contained in:
javanna 2016-07-18 18:13:14 +02:00 committed by Luca Cavanna
parent f2ab597c84
commit 1bb33cf572
4 changed files with 8 additions and 10 deletions

View File

@ -20,7 +20,6 @@ package org.elasticsearch.client;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
@ -37,7 +36,6 @@ import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpTrace;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.nio.client.methods.HttpAsyncMethods;
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
@ -79,7 +77,6 @@ import java.util.concurrent.atomic.AtomicInteger;
public final class RestClient implements Closeable {
private static final Log logger = LogFactory.getLog(RestClient.class);
public static ContentType JSON_CONTENT_TYPE = ContentType.create("application/json", Consts.UTF_8);
private final CloseableHttpAsyncClient client;
//we don't rely on default headers supported by HttpAsyncClient as those cannot be replaced

View File

@ -20,16 +20,15 @@ package org.elasticsearch.http;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.plugins.Plugin;
import org.hamcrest.Matcher;
import java.io.IOException;
@ -103,7 +102,7 @@ public class DeprecationHttpIT extends HttpSmokeTestCase {
// trigger all index deprecations
Response response = getRestClient().performRequest("GET", "/" + commaSeparatedIndices + "/_search",
Collections.emptyMap(), new StringEntity(body, RestClient.JSON_CONTENT_TYPE));
Collections.emptyMap(), new StringEntity(body, ContentType.APPLICATION_JSON));
assertThat(response.getStatusLine().getStatusCode(), equalTo(OK.getStatus()));
final List<String> deprecatedWarnings = getWarningHeaders(response.getHeaders());
@ -201,7 +200,7 @@ public class DeprecationHttpIT extends HttpSmokeTestCase {
builder.endArray().endObject();
return new StringEntity(builder.string(), RestClient.JSON_CONTENT_TYPE);
return new StringEntity(builder.string(), ContentType.APPLICATION_JSON);
}
}

View File

@ -19,6 +19,7 @@
package org.elasticsearch.http;
import org.apache.http.HttpHeaders;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.elasticsearch.client.Response;
@ -35,7 +36,7 @@ public class HttpCompressionIT extends ESIntegTestCase {
" \"first name\": \"Steve\",\n" +
" \"last name\": \"Jobs\"\n" +
" }\n" +
"}", RestClient.JSON_CONTENT_TYPE);
"}", ContentType.APPLICATION_JSON);
@Override
protected boolean ignoreExternalCluster() {

View File

@ -22,6 +22,7 @@ import com.carrotsearch.randomizedtesting.RandomizedTest;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
@ -135,7 +136,7 @@ public class RestTestClient implements Closeable {
String path = "/"+ Objects.requireNonNull(queryStringParams.remove("path"), "Path must be set to use raw request");
HttpEntity entity = null;
if (body != null && body.length() > 0) {
entity = new StringEntity(body, RestClient.JSON_CONTENT_TYPE);
entity = new StringEntity(body, ContentType.APPLICATION_JSON);
}
// And everything else is a url parameter!
try {
@ -204,7 +205,7 @@ public class RestTestClient implements Closeable {
requestMethod = "GET";
} else {
requestMethod = RandomizedTest.randomFrom(supportedMethods);
requestBody = new StringEntity(body, RestClient.JSON_CONTENT_TYPE);
requestBody = new StringEntity(body, ContentType.APPLICATION_JSON);
}
} else {
if (restApi.isBodyRequired()) {