Răsfoiți Sursa

Re-enable compiler warnings in :test:framework (#75449)

Part of #40366.
Rory Hunter 4 ani în urmă
părinte
comite
cd4446732e

+ 1 - 3
test/framework/build.gradle

@@ -37,8 +37,6 @@ dependencies {
   api "org.apache.commons:commons-lang3:${versions.commons_lang3}"
 }
 
-tasks.named("compileJava").configure { options.compilerArgs << '-Xlint:-cast,-unchecked' }
-
 // the main files are actually test files, so use the appropriate forbidden api sigs
 tasks.named('forbiddenApisMain').configure {
   replaceSignatureFiles 'jdk-signatures', 'es-all-signatures', 'es-test-signatures'
@@ -110,6 +108,6 @@ tasks.register("verifyVersions") {
 }
 
 tasks.named('splitPackagesAudit').configure {
-  // for now we always run tests with the classpath, so we are ok with split packages for tests 
+  // for now we always run tests with the classpath, so we are ok with split packages for tests
   onlyIf { false }
 }

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java

@@ -478,6 +478,7 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
         }
 
         @Override
+        @SuppressWarnings("unchecked")
         public Iterator<IndexShard> iterator() {
             return Iterators.concat(replicas.iterator(), Collections.singleton(primary).iterator());
         }

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/ingest/TestTemplateService.java

@@ -37,6 +37,7 @@ public class TestTemplateService extends ScriptService {
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public <FactoryType> FactoryType compile(Script script, ScriptContext<FactoryType> context) {
         if (this.compilationException) {
             throw new RuntimeException("could not compile script");

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java

@@ -435,6 +435,7 @@ public abstract class AggregatorTestCase extends ESTestCase {
      *          for each leaf as though it were a separate index. If false this aggregates
      *          all leaves together, like we do in production.
      */
+    @SuppressWarnings("unchecked")
     protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduce(IndexSettings indexSettings,
                                                                                       IndexSearcher searcher,
                                                                                       Query query,

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java

@@ -163,6 +163,7 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase {
         }
     }
 
+    @SuppressWarnings("cast")
     protected RepositoryData getRepositoryData(String repository) {
         return getRepositoryData((Repository) getRepositoryOnMaster(repository));
     }

+ 2 - 0
test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java

@@ -1091,6 +1091,8 @@ public abstract class ESTestCase extends LuceneTestCase {
     /**
      * Returns size random values
      */
+    @SafeVarargs
+    @SuppressWarnings("varargs")
     public static <T> List<T> randomSubsetOf(int size, T... values) {
         List<T> list = arrayAsArrayList(values);
         return randomSubsetOf(size, list);

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/test/InternalAggregationTestCase.java

@@ -322,6 +322,7 @@ public abstract class InternalAggregationTestCase<T extends InternalAggregation>
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     protected final Class<T> categoryClass() {
         return (Class<T>) InternalAggregation.class;
     }

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisruption.java

@@ -181,6 +181,7 @@ public class NetworkDisruption implements ServiceDisruptionScheme {
     public abstract static class DisruptedLinks {
         private final Set<String> nodes;
 
+        @SafeVarargs
         protected DisruptedLinks(Set<String>... nodeSets) {
             Set<String> allNodes = new HashSet<>();
             for (Set<String> nodeSet : nodeSets) {

+ 7 - 6
test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

@@ -33,15 +33,10 @@ import org.elasticsearch.client.ResponseException;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder;
 import org.elasticsearch.client.WarningsHandler;
-import org.elasticsearch.core.CharArrays;
-import org.elasticsearch.core.CheckedRunnable;
-import org.elasticsearch.core.Nullable;
 import org.elasticsearch.common.Strings;
-import org.elasticsearch.core.PathUtils;
 import org.elasticsearch.common.settings.SecureString;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.ssl.PemUtils;
-import org.elasticsearch.core.TimeValue;
 import org.elasticsearch.common.util.concurrent.ThreadContext;
 import org.elasticsearch.common.util.set.Sets;
 import org.elasticsearch.common.xcontent.DeprecationHandler;
@@ -52,6 +47,11 @@ import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.common.xcontent.XContentType;
 import org.elasticsearch.common.xcontent.json.JsonXContent;
 import org.elasticsearch.common.xcontent.support.XContentMapValues;
+import org.elasticsearch.core.CharArrays;
+import org.elasticsearch.core.CheckedRunnable;
+import org.elasticsearch.core.Nullable;
+import org.elasticsearch.core.PathUtils;
+import org.elasticsearch.core.TimeValue;
 import org.elasticsearch.core.internal.io.IOUtils;
 import org.elasticsearch.index.IndexSettings;
 import org.elasticsearch.index.seqno.ReplicationTracker;
@@ -64,7 +64,6 @@ import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 
-import javax.net.ssl.SSLContext;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -97,6 +96,7 @@ import java.util.function.Consumer;
 import java.util.function.Predicate;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import javax.net.ssl.SSLContext;
 
 import static java.util.Collections.sort;
 import static java.util.Collections.unmodifiableList;
@@ -1010,6 +1010,7 @@ public abstract class ESRestTestCase extends ESTestCase {
         }
     }
 
+    @SuppressWarnings("unchecked")
     private static void deleteAllAutoFollowPatterns() throws IOException {
         final List<Map<?, ?>> patterns;
 

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ContainsAssertion.java

@@ -39,6 +39,7 @@ public class ContainsAssertion extends Assertion {
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     protected void doAssert(Object actualValue, Object expectedValue) {
         // add support for matching objects ({a:b}) against list of objects ([ {a:b, c:d} ])
         if(expectedValue instanceof Map && actualValue instanceof List) {

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/GreaterThanAssertion.java

@@ -42,6 +42,7 @@ public class GreaterThanAssertion extends Assertion {
     }
 
     @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
     protected void doAssert(Object actualValue, Object expectedValue) {
         logger.trace("assert that [{}] is greater than [{}] (field: [{}])", actualValue, expectedValue, getField());
         assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/GreaterThanEqualToAssertion.java

@@ -43,6 +43,7 @@ public class GreaterThanEqualToAssertion extends Assertion {
     }
 
     @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
     protected void doAssert(Object actualValue, Object expectedValue) {
         logger.trace("assert that [{}] is greater than or equal to [{}] (field: [{}])", actualValue, expectedValue, getField());
         assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/LessThanAssertion.java

@@ -43,6 +43,7 @@ public class LessThanAssertion extends Assertion {
     }
 
     @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
     protected void doAssert(Object actualValue, Object expectedValue) {
         logger.trace("assert that [{}] is less than [{}] (field: [{}])", actualValue, expectedValue, getField());
         assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",

+ 1 - 0
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/LessThanOrEqualToAssertion.java

@@ -43,6 +43,7 @@ public class LessThanOrEqualToAssertion  extends Assertion {
     }
 
     @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
     protected void doAssert(Object actualValue, Object expectedValue) {
         logger.trace("assert that [{}] is less than or equal to [{}] (field: [{}])", actualValue, expectedValue, getField());
         assertThat("value of [" + getField() + "] is not comparable (got [" + safeClass(actualValue) + "])",