Remove Xlint exclusions from gradle files
Backport of #52542. This commit is part of issue #40366 to remove disabled Xlint warnings from gradle files. In particular, it removes the Xlint exclusions from the following files: - benchmarks/build.gradle - client/client-benchmark-noop-api-plugin/build.gradle - x-pack/qa/rolling-upgrade/build.gradle - x-pack/qa/third-party/active-directory/build.gradle - modules/transport-netty4/build.gradle For the first three files no code adjustments were needed. For x-pack/qa/third-party/active-directory move the suppression at the code level. For transport-netty4 replace the variable arguments with ArrayLists and remove any redundant casts.
This commit is contained in:
parent
d76358c875
commit
ba8d6d1fb5
|
@ -41,7 +41,6 @@ dependencies {
|
||||||
runtime 'org.apache.commons:commons-math3:3.2'
|
runtime 'org.apache.commons:commons-math3:3.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked,-processing"
|
|
||||||
// enable the JMH's BenchmarkProcessor to generate the final benchmark classes
|
// enable the JMH's BenchmarkProcessor to generate the final benchmark classes
|
||||||
// needs to be added separately otherwise Gradle will quote it and javac will fail
|
// needs to be added separately otherwise Gradle will quote it and javac will fail
|
||||||
compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])
|
compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])
|
||||||
|
|
|
@ -33,8 +33,6 @@ assemble.enabled = false
|
||||||
dependencyLicenses.enabled = false
|
dependencyLicenses.enabled = false
|
||||||
dependenciesInfo.enabled = false
|
dependenciesInfo.enabled = false
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
|
||||||
|
|
||||||
// no unit tests
|
// no unit tests
|
||||||
test.enabled = false
|
test.enabled = false
|
||||||
integTest.enabled = false
|
integTest.enabled = false
|
||||||
|
|
|
@ -33,8 +33,6 @@ esplugin {
|
||||||
hasClientJar = true
|
hasClientJar = true
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// network stack
|
// network stack
|
||||||
compile "io.netty:netty-buffer:${versions.netty}"
|
compile "io.netty:netty-buffer:${versions.netty}"
|
||||||
|
|
|
@ -102,8 +102,7 @@ class Netty4HttpClient implements Closeable {
|
||||||
return sendRequests(remoteAddress, requests);
|
return sendRequests(remoteAddress, requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs // Safe not because it doesn't do anything with the type parameters but because it won't leak them into other methods.
|
public final Collection<FullHttpResponse> post(SocketAddress remoteAddress, List<Tuple<String, CharSequence>> urisAndBodies)
|
||||||
public final Collection<FullHttpResponse> post(SocketAddress remoteAddress, Tuple<String, CharSequence>... urisAndBodies)
|
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
return processRequestsWithBody(HttpMethod.POST, remoteAddress, urisAndBodies);
|
return processRequestsWithBody(HttpMethod.POST, remoteAddress, urisAndBodies);
|
||||||
}
|
}
|
||||||
|
@ -114,15 +113,14 @@ class Netty4HttpClient implements Closeable {
|
||||||
return responses.iterator().next();
|
return responses.iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs // Safe not because it doesn't do anything with the type parameters but because it won't leak them into other methods.
|
public final Collection<FullHttpResponse> put(SocketAddress remoteAddress, List<Tuple<String, CharSequence>> urisAndBodies)
|
||||||
public final Collection<FullHttpResponse> put(SocketAddress remoteAddress, Tuple<String, CharSequence>... urisAndBodies)
|
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
return processRequestsWithBody(HttpMethod.PUT, remoteAddress, urisAndBodies);
|
return processRequestsWithBody(HttpMethod.PUT, remoteAddress, urisAndBodies);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<FullHttpResponse> processRequestsWithBody(HttpMethod method, SocketAddress remoteAddress, Tuple<String,
|
private Collection<FullHttpResponse> processRequestsWithBody(HttpMethod method, SocketAddress remoteAddress, List<Tuple<String,
|
||||||
CharSequence>... urisAndBodies) throws InterruptedException {
|
CharSequence>> urisAndBodies) throws InterruptedException {
|
||||||
Collection<HttpRequest> requests = new ArrayList<>(urisAndBodies.length);
|
Collection<HttpRequest> requests = new ArrayList<>(urisAndBodies.size());
|
||||||
for (Tuple<String, CharSequence> uriAndBody : urisAndBodies) {
|
for (Tuple<String, CharSequence> uriAndBody : urisAndBodies) {
|
||||||
ByteBuf content = Unpooled.copiedBuffer(uriAndBody.v2(), StandardCharsets.UTF_8);
|
ByteBuf content = Unpooled.copiedBuffer(uriAndBody.v2(), StandardCharsets.UTF_8);
|
||||||
HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, uriAndBody.v1(), content);
|
HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, uriAndBody.v1(), content);
|
||||||
|
|
|
@ -33,7 +33,9 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
import static org.hamcrest.Matchers.greaterThan;
|
||||||
|
@ -77,25 +79,23 @@ public class Netty4HttpRequestSizeLimitIT extends ESNetty4IntegTestCase {
|
||||||
bulkRequest.append(System.lineSeparator());
|
bulkRequest.append(System.lineSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
List<Tuple<String, CharSequence>> requests = new ArrayList<>();
|
||||||
Tuple<String, CharSequence>[] requests = new Tuple[150];
|
for (int i = 0; i < 150; i++) {
|
||||||
for (int i = 0; i < requests.length; i++) {
|
requests.add(Tuple.tuple("/index/type/_bulk", bulkRequest));
|
||||||
requests[i] = Tuple.tuple("/index/type/_bulk", bulkRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
|
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
|
||||||
TransportAddress transportAddress = (TransportAddress) randomFrom(httpServerTransport.boundAddress
|
TransportAddress transportAddress = randomFrom(httpServerTransport.boundAddress().boundAddresses());
|
||||||
().boundAddresses());
|
|
||||||
|
|
||||||
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
|
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
|
||||||
Collection<FullHttpResponse> singleResponse = nettyHttpClient.post(transportAddress.address(), requests[0]);
|
Collection<FullHttpResponse> singleResponse = nettyHttpClient.post(transportAddress.address(), requests.subList(0, 1));
|
||||||
try {
|
try {
|
||||||
assertThat(singleResponse, hasSize(1));
|
assertThat(singleResponse, hasSize(1));
|
||||||
assertAtLeastOnceExpectedStatus(singleResponse, HttpResponseStatus.OK);
|
assertAtLeastOnceExpectedStatus(singleResponse, HttpResponseStatus.OK);
|
||||||
|
|
||||||
Collection<FullHttpResponse> multipleResponses = nettyHttpClient.post(transportAddress.address(), requests);
|
Collection<FullHttpResponse> multipleResponses = nettyHttpClient.post(transportAddress.address(), requests);
|
||||||
try {
|
try {
|
||||||
assertThat(multipleResponses, hasSize(requests.length));
|
assertThat(multipleResponses, hasSize(requests.size()));
|
||||||
assertAtLeastOnceExpectedStatus(multipleResponses, HttpResponseStatus.TOO_MANY_REQUESTS);
|
assertAtLeastOnceExpectedStatus(multipleResponses, HttpResponseStatus.TOO_MANY_REQUESTS);
|
||||||
} finally {
|
} finally {
|
||||||
multipleResponses.forEach(ReferenceCounted::release);
|
multipleResponses.forEach(ReferenceCounted::release);
|
||||||
|
@ -109,21 +109,19 @@ public class Netty4HttpRequestSizeLimitIT extends ESNetty4IntegTestCase {
|
||||||
public void testDoesNotLimitExcludedRequests() throws Exception {
|
public void testDoesNotLimitExcludedRequests() throws Exception {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
List<Tuple<String, CharSequence>> requestUris = new ArrayList<>();
|
||||||
Tuple<String, CharSequence>[] requestUris = new Tuple[1500];
|
for (int i = 0; i < 1500; i++) {
|
||||||
for (int i = 0; i < requestUris.length; i++) {
|
requestUris.add(Tuple.tuple("/_cluster/settings",
|
||||||
requestUris[i] = Tuple.tuple("/_cluster/settings",
|
"{ \"transient\": {\"search.default_search_timeout\": \"40s\" } }"));
|
||||||
"{ \"transient\": {\"search.default_search_timeout\": \"40s\" } }");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
|
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
|
||||||
TransportAddress transportAddress = (TransportAddress) randomFrom(httpServerTransport.boundAddress
|
TransportAddress transportAddress = randomFrom(httpServerTransport.boundAddress().boundAddresses());
|
||||||
().boundAddresses());
|
|
||||||
|
|
||||||
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
|
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
|
||||||
Collection<FullHttpResponse> responses = nettyHttpClient.put(transportAddress.address(), requestUris);
|
Collection<FullHttpResponse> responses = nettyHttpClient.put(transportAddress.address(), requestUris);
|
||||||
try {
|
try {
|
||||||
assertThat(responses, hasSize(requestUris.length));
|
assertThat(responses, hasSize(requestUris.size()));
|
||||||
assertAllInExpectedStatus(responses, HttpResponseStatus.OK);
|
assertAllInExpectedStatus(responses, HttpResponseStatus.OK);
|
||||||
} finally {
|
} finally {
|
||||||
responses.forEach(ReferenceCounted::release);
|
responses.forEach(ReferenceCounted::release);
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class Netty4TransportPublishAddressIT extends ESNetty4IntegTestCase {
|
||||||
assertThat(boundTransportAddress.boundAddresses().length, greaterThan(1));
|
assertThat(boundTransportAddress.boundAddresses().length, greaterThan(1));
|
||||||
for (TransportAddress boundAddress : boundTransportAddress.boundAddresses()) {
|
for (TransportAddress boundAddress : boundTransportAddress.boundAddresses()) {
|
||||||
assertThat(boundAddress, instanceOf(TransportAddress.class));
|
assertThat(boundAddress, instanceOf(TransportAddress.class));
|
||||||
TransportAddress inetBoundAddress = (TransportAddress) boundAddress;
|
TransportAddress inetBoundAddress = boundAddress;
|
||||||
if (inetBoundAddress.address().getAddress() instanceof Inet4Address) {
|
if (inetBoundAddress.address().getAddress() instanceof Inet4Address) {
|
||||||
// IPv4 address is preferred publish address for _local_
|
// IPv4 address is preferred publish address for _local_
|
||||||
assertThat(inetBoundAddress.getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
|
assertThat(inetBoundAddress.getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
|
||||||
|
|
|
@ -10,8 +10,6 @@ dependencies {
|
||||||
testCompile project(':client:rest-high-level')
|
testCompile project(':client:rest-high-level')
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
|
||||||
|
|
||||||
forbiddenPatterns {
|
forbiddenPatterns {
|
||||||
exclude '**/system_key'
|
exclude '**/system_key'
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,6 +361,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private Map<Version, RestClient> getRestClientByVersion() throws IOException {
|
private Map<Version, RestClient> getRestClientByVersion() throws IOException {
|
||||||
Response response = client().performRequest(new Request("GET", "_nodes"));
|
Response response = client().performRequest(new Request("GET", "_nodes"));
|
||||||
assertOK(response);
|
assertOK(response);
|
||||||
|
@ -404,6 +405,7 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase {
|
||||||
assertOK(indexResponse1);
|
assertOK(indexResponse1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, Object> retrieveStoredTokens(RestClient client, int tokenIdx) throws IOException {
|
private Map<String, Object> retrieveStoredTokens(RestClient client, int tokenIdx) throws IOException {
|
||||||
Request getRequest = new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token" + tokenIdx);
|
Request getRequest = new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token" + tokenIdx);
|
||||||
Response getResponse = client().performRequest(getRequest);
|
Response getResponse = client().performRequest(getRequest);
|
||||||
|
|
|
@ -13,8 +13,6 @@ processTestResources {
|
||||||
from(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
|
from(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
|
||||||
|
|
||||||
// we have to repeat these patterns because the security test resources are effectively in the src of this p
|
// we have to repeat these patterns because the security test resources are effectively in the src of this p
|
||||||
forbiddenPatterns {
|
forbiddenPatterns {
|
||||||
exclude '**/*.key'
|
exclude '**/*.key'
|
||||||
|
|
Loading…
Reference in New Issue