Skip to content

Commit

Permalink
Re-enable compiler warnings in :test:framework (#75449)
Browse files Browse the repository at this point in the history
Part of #40366.
  • Loading branch information
pugnascotia committed Jul 21, 2021
1 parent c414f3b commit 400029a
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 9 deletions.
4 changes: 1 addition & 3 deletions test/framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -113,6 +111,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 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ public synchronized void close() throws Exception {
}

@Override
@SuppressWarnings("unchecked")
public Iterator<IndexShard> iterator() {
return Iterators.concat(replicas.iterator(), Collections.singleton(primary).iterator());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private TestTemplateService(boolean compilationException) {
}

@Override
@SuppressWarnings("unchecked")
public <FactoryType> FactoryType compile(Script script, ScriptContext<FactoryType> context) {
if (this.compilationException) {
throw new RuntimeException("could not compile script");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
* 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ protected RepositoryData getRepositoryData(String repoName, Version version) {
}
}

@SuppressWarnings("cast")
protected RepositoryData getRepositoryData(String repository) {
return getRepositoryData((Repository) getRepositoryOnMaster(repository));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,8 @@ public static Settings.Builder settings(Version version) {
/**
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ protected T createUnmappedInstance(String name, Map<String, Object> metadata) {
}

@Override
@SuppressWarnings("unchecked")
protected final Class<T> categoryClass() {
return (Class<T>) InternalAggregation.class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public String toString() {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,10 @@
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;
Expand All @@ -52,6 +47,11 @@
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;
Expand All @@ -65,7 +65,6 @@
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;
Expand Down Expand Up @@ -99,6 +98,7 @@
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;
Expand Down Expand Up @@ -1043,6 +1043,7 @@ private static void deleteAllSLMPolicies() throws IOException {
}
}

@SuppressWarnings("unchecked")
private static void deleteAllAutoFollowPatterns() throws IOException {
final List<Map<?, ?>> patterns;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public ClientYamlTestResponse callApi(String apiName, Map<String, String> params
* This functionality is supported in 7.x, but is not supported in 6.x (or is not the default
* behavior). Here we modify the request so that it will work against a 6.x node.
*/
@SuppressWarnings("unchecked")
private void adaptRequestForOlderVersion(String apiName,
List<Map<String, Object>> bodies,
Map<String, String> requestParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public ContainsAssertion(XContentLocation location, String field, Object expecte
}

@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public GreaterThanAssertion(XContentLocation location, String field, Object expe
}

@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) + "])",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public GreaterThanEqualToAssertion(XContentLocation location, String field, Obje
}

@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) + "])",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public LessThanAssertion(XContentLocation location, String field, Object expecte
}

@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) + "])",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public LessThanOrEqualToAssertion(XContentLocation location, String field, Objec
}

@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) + "])",
Expand Down

0 comments on commit 400029a

Please sign in to comment.