Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,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 @@ -435,6 +435,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 @@ -163,6 +163,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 @@ -1091,6 +1091,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 @@ -322,6 +322,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 @@ -64,7 +64,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 @@ -97,6 +96,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 @@ -1010,6 +1010,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 @@ -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