Skip to content

Commit

Permalink
Merge pull request #13410 from rjernst/you_were_warned
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
rjernst committed Sep 9, 2015
2 parents 9e6115b + 9e8a90a commit 9d71f07
Show file tree
Hide file tree
Showing 40 changed files with 77 additions and 42 deletions.
4 changes: 4 additions & 0 deletions core/pom.xml
Expand Up @@ -15,6 +15,10 @@
<name>Elasticsearch: Core</name>
<description>Elasticsearch - Open Source, Distributed, RESTful Search Engine</description>

<properties>
<xlint.options>-Xlint:-cast,-deprecation,-fallthrough,-overrides,-rawtypes,-serial,-try,-unchecked</xlint.options>
</properties>

<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
Expand Down
Expand Up @@ -36,6 +36,8 @@
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

import java.util.Arrays;

/**
* Close index action
*/
Expand Down Expand Up @@ -92,7 +94,7 @@ public void onResponse(ClusterStateUpdateResponse response) {

@Override
public void onFailure(Throwable t) {
logger.debug("failed to close indices [{}]", t, concreteIndices);
logger.debug("failed to close indices [{}]", t, (Object)concreteIndices);
listener.onFailure(t);
}
});
Expand Down
Expand Up @@ -36,6 +36,8 @@
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

import java.util.Arrays;

/**
* Open index action
*/
Expand Down Expand Up @@ -92,7 +94,7 @@ public void onResponse(ClusterStateUpdateResponse response) {

@Override
public void onFailure(Throwable t) {
logger.debug("failed to open indices [{}]", t, concreteIndices);
logger.debug("failed to open indices [{}]", t, (Object)concreteIndices);
listener.onFailure(t);
}
});
Expand Down
Expand Up @@ -35,6 +35,8 @@
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

import java.util.Arrays;

/**
*
*/
Expand Down Expand Up @@ -90,7 +92,7 @@ public void onResponse(ClusterStateUpdateResponse response) {

@Override
public void onFailure(Throwable t) {
logger.debug("failed to update settings on indices [{}]", t, concreteIndices);
logger.debug("failed to update settings on indices [{}]", t, (Object)concreteIndices);
listener.onFailure(t);
}
});
Expand Down
Expand Up @@ -668,6 +668,7 @@ public List<String> resolve(final Context context, List<String> expressions) {
return result;
}

@SuppressWarnings("fallthrough")
String resolveExpression(String expression, final Context context) {
if (expression.startsWith(EXPRESSION_LEFT_BOUND) == false || expression.endsWith(EXPRESSION_RIGHT_BOUND) == false) {
return expression;
Expand Down
Expand Up @@ -30,6 +30,7 @@
* @param <I> the injectable type encountered
* @since 2.0
*/
@SuppressWarnings("overloads")
public interface TypeEncounter<I> {

/**
Expand Down
Expand Up @@ -71,7 +71,7 @@ public static class NodePath {
public NodePath(Path path, Environment environment) throws IOException {
this.path = path;
this.indicesPath = path.resolve(INDICES_FOLDER);
this.fileStore = environment.getFileStore(path);
this.fileStore = Environment.getFileStore(path);
if (fileStore.supportsFileAttributeView("lucene")) {
this.spins = (Boolean) fileStore.getAttribute("lucene:spins");
} else {
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/elasticsearch/gateway/Gateway.java
Expand Up @@ -33,6 +33,7 @@
import org.elasticsearch.env.NodeEnvironment;

import java.nio.file.Path;
import java.util.Arrays;

/**
*
Expand Down Expand Up @@ -171,7 +172,7 @@ protected int calcRequiredAllocations(final String setting, final int nodeCount)
public void reset() throws Exception {
try {
Path[] dataPaths = nodeEnv.nodeDataPaths();
logger.trace("removing node data paths: [{}]", dataPaths);
logger.trace("removing node data paths: [{}]", (Object)dataPaths);
IOUtils.rm(dataPaths);
} catch (Exception ex) {
logger.debug("failed to delete shard locations", ex);
Expand Down
Expand Up @@ -59,6 +59,7 @@ public void reset(String field) {

public void postProcess(MappedFieldType fieldType) {
if (uid != null) {
// TODO: this switch seems very wrong...either each case should be breaking, or this should not be a switch
switch (field) {
case UidFieldMapper.NAME: addValue(field, uid.toString());
case IdFieldMapper.NAME: addValue(field, uid.id());
Expand Down
Expand Up @@ -77,10 +77,10 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if (parseContext.parseFieldMatcher().match(currentFieldName, QUERY_FIELD)) {
innerQuery = new XContentStructure.InnerQuery(parseContext, null);
innerQuery = new XContentStructure.InnerQuery(parseContext, (String[])null);
queryFound = true;
} else if (parseContext.parseFieldMatcher().match(currentFieldName, NO_MATCH_QUERY)) {
innerNoMatchQuery = new XContentStructure.InnerQuery(parseContext, null);
innerNoMatchQuery = new XContentStructure.InnerQuery(parseContext, (String[])null);
} else {
throw new QueryParsingException(parseContext, "[indices] query does not support [" + currentFieldName + "]");
}
Expand Down
Expand Up @@ -59,7 +59,7 @@ public ScoreFunctionParserMapper(Set<ScoreFunctionParser> parsers) {
public ScoreFunctionParser get(QueryParseContext parseContext, String parserName) {
ScoreFunctionParser functionParser = get(parserName);
if (functionParser == null) {
throw new QueryParsingException(parseContext, "No function with the name [" + parserName + "] is registered.", null);
throw new QueryParsingException(parseContext, "No function with the name [" + parserName + "] is registered.");
}
return functionParser;
}
Expand Down
Expand Up @@ -40,7 +40,7 @@ public PercentilesBucketBuilder percents(Double[] percents) {
@Override
protected void doInternalXContent(XContentBuilder builder, Params params) throws IOException {
if (percents != null) {
builder.field(PercentilesBucketParser.PERCENTS.getPreferredName(), percents);
builder.field(PercentilesBucketParser.PERCENTS.getPreferredName(), (Object[])percents);
}
}

Expand Down
Expand Up @@ -227,6 +227,7 @@ public TopDocs call() throws Exception {
// set the last emitted doc
scrollContext.lastEmittedDoc = topDocs.scoreDocs[topDocs.scoreDocs.length - 1];
}
break;
default:
break;
}
Expand Down
Expand Up @@ -442,7 +442,7 @@ private void bindServerBootstrap(final String name, final Settings settings) {
for (int i = 0; i < hostAddresses.length; i++) {
addresses[i] = NetworkAddress.format(hostAddresses[i]);
}
logger.debug("binding server bootstrap to: {}", addresses);
logger.debug("binding server bootstrap to: {}", (Object)addresses);
}
for (InetAddress hostAddress : hostAddresses) {
bindServerBootstrap(name, hostAddress, settings);
Expand Down
Expand Up @@ -60,7 +60,7 @@ public void testAnalyzerTokensAfterUpgrade() throws IOException, ExecutionExcept
fields[i] = "type=string,analyzer=" + analyzer;
}
assertAcked(prepareCreate("test")
.addMapping("type", fields)
.addMapping("type", (Object[])fields)
.setSettings(indexSettings()));
ensureYellow();
InputOutput[] inout = new InputOutput[numFields];
Expand Down
Expand Up @@ -114,14 +114,14 @@ public void testIndexOptions_strict() {
String[] results = indexNameExpressionResolver.concreteIndices(context, Strings.EMPTY_ARRAY);
assertEquals(3, results.length);

results = indexNameExpressionResolver.concreteIndices(context, null);
results = indexNameExpressionResolver.concreteIndices(context, (String[])null);
assertEquals(3, results.length);

context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpand());
results = indexNameExpressionResolver.concreteIndices(context, Strings.EMPTY_ARRAY);
assertEquals(4, results.length);

results = indexNameExpressionResolver.concreteIndices(context, null);
results = indexNameExpressionResolver.concreteIndices(context, (String[])null);
assertEquals(4, results.length);

context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictExpandOpen());
Expand Down Expand Up @@ -348,7 +348,7 @@ public void testIndexOptions_noExpandWildcards() {
assertEquals(2, results.length);
assertThat(results, arrayContainingInAnyOrder("foo", "foobar"));

results = indexNameExpressionResolver.concreteIndices(context, null);
results = indexNameExpressionResolver.concreteIndices(context, (String[])null);
assertEquals(0, results.length);

results = indexNameExpressionResolver.concreteIndices(context, Strings.EMPTY_ARRAY);
Expand Down
Expand Up @@ -179,7 +179,7 @@ public int compare(Path o1, Path o2) {
OldIndexBackwardsCompatibilityIT.copyIndex(logger, src, indexName, multiDataPath);
final ShardPath shardPath = new ShardPath(false, nodeEnvironment.availableShardPaths(new ShardId(indexName, 0))[0], nodeEnvironment.availableShardPaths(new ShardId(indexName, 0))[0], IndexMetaData.INDEX_UUID_NA_VALUE, new ShardId(indexName, 0));

logger.info("{}", FileSystemUtils.files(shardPath.resolveIndex()));
logger.info("{}", (Object)FileSystemUtils.files(shardPath.resolveIndex()));

MultiDataPathUpgrader helper = new MultiDataPathUpgrader(nodeEnvironment);
helper.upgrade(new ShardId(indexName, 0), shardPath);
Expand Down
Expand Up @@ -148,7 +148,7 @@ public void testLockTryingToDelete() throws Exception {
ensureGreen();
NodeEnvironment env = getInstanceFromNode(NodeEnvironment.class);
Path[] shardPaths = env.availableShardPaths(new ShardId("test", 0));
logger.info("--> paths: [{}]", shardPaths);
logger.info("--> paths: [{}]", (Object)shardPaths);
// Should not be able to acquire the lock because it's already open
try {
NodeEnvironment.acquireFSLockForPaths(Settings.EMPTY, shardPaths);
Expand Down
Expand Up @@ -390,7 +390,7 @@ public void testSnapshotWithNewTranslog() throws IOException {
}

public void testSnapshotOnClosedTranslog() throws IOException {
assertTrue(Files.exists(translogDir.resolve(translog.getFilename(1))));
assertTrue(Files.exists(translogDir.resolve(Translog.getFilename(1))));
translog.add(new Translog.Create("test", "1", new byte[]{1}));
translog.close();
try {
Expand Down Expand Up @@ -436,14 +436,14 @@ public void deleteOnSnapshotRelease() throws Exception {


public void assertFileIsPresent(Translog translog, long id) {
if (Files.exists(translogDir.resolve(translog.getFilename(id)))) {
if (Files.exists(translogDir.resolve(Translog.getFilename(id)))) {
return;
}
fail(translog.getFilename(id) + " is not present in any location: " + translog.location());
fail(Translog.getFilename(id) + " is not present in any location: " + translog.location());
}

public void assertFileDeleted(Translog translog, long id) {
assertFalse("translog [" + id + "] still exists", Files.exists(translog.location().resolve(translog.getFilename(id))));
assertFalse("translog [" + id + "] still exists", Files.exists(translog.location().resolve(Translog.getFilename(id))));
}

static class LocationOperation {
Expand Down Expand Up @@ -913,7 +913,7 @@ public void testBasicCheckpoint() throws IOException {
final Translog.Location lastLocation = translog.add(new Translog.Create("test", "" + translogOperations, Integer.toString(translogOperations).getBytes(Charset.forName("UTF-8"))));

final Checkpoint checkpoint = Checkpoint.read(translog.location().resolve(Translog.CHECKPOINT_FILE_NAME));
try (final ImmutableTranslogReader reader = translog.openReader(translog.location().resolve(translog.getFilename(translog.currentFileGeneration())), checkpoint)) {
try (final ImmutableTranslogReader reader = translog.openReader(translog.location().resolve(Translog.getFilename(translog.currentFileGeneration())), checkpoint)) {
assertEquals(lastSynced + 1, reader.totalOperations());
for (int op = 0; op < translogOperations; op++) {
Translog.Location location = locations.get(op);
Expand Down
Expand Up @@ -196,7 +196,7 @@ public void testCloseNoIndex() {
@Test(expected = ActionRequestValidationException.class)
public void testCloseNullIndex() {
Client client = client();
client.admin().indices().prepareClose(null).execute().actionGet();
client.admin().indices().prepareClose((String[])null).execute().actionGet();
}

@Test(expected = ActionRequestValidationException.class)
Expand All @@ -208,7 +208,7 @@ public void testOpenNoIndex() {
@Test(expected = ActionRequestValidationException.class)
public void testOpenNullIndex() {
Client client = client();
client.admin().indices().prepareOpen(null).execute().actionGet();
client.admin().indices().prepareOpen((String[])null).execute().actionGet();
}

@Test
Expand Down
Expand Up @@ -263,7 +263,7 @@ public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
@Test
public void testThatInvalidGetIndexTemplatesFails() throws Exception {
logger.info("--> get template null");
testExpectActionRequestValidationException(null);
testExpectActionRequestValidationException((String[])null);

logger.info("--> get template empty");
testExpectActionRequestValidationException("");
Expand Down
Expand Up @@ -306,9 +306,8 @@ private void testMinDocCountOnTerms(String field, Script script, Terms.Order ord
testMinDocCountOnTerms(field, script, order, include, false);
} catch (Throwable secondFailure) {
logger.error("exception on retry (will re-throw the original in a sec)", secondFailure);
} finally {
throw ae;
}
throw ae;
}
}

Expand Down
Expand Up @@ -1365,7 +1365,8 @@ public void testBasicFilterById() throws Exception {
assertHitCount(searchResponse, 1l);
assertThat(searchResponse.getHits().hits().length, equalTo(1));

searchResponse = client().prepareSearch().setQuery(constantScoreQuery(idsQuery(null).ids("1"))).get();
// TODO: why do we even support passing null??
searchResponse = client().prepareSearch().setQuery(constantScoreQuery(idsQuery((String[])null).ids("1"))).get();
assertHitCount(searchResponse, 1l);
assertThat(searchResponse.getHits().hits().length, equalTo(1));

Expand Down Expand Up @@ -1403,7 +1404,7 @@ public void testBasicQueryById() throws Exception {
assertHitCount(searchResponse, 1l);
assertThat(searchResponse.getHits().hits().length, equalTo(1));

searchResponse = client().prepareSearch().setQuery(idsQuery(null).ids("1")).get();
searchResponse = client().prepareSearch().setQuery(idsQuery((String[])null).ids("1")).get();
assertHitCount(searchResponse, 1l);
assertThat(searchResponse.getHits().hits().length, equalTo(1));

Expand Down
Expand Up @@ -170,7 +170,7 @@ public void testMappingIdempotency() throws Exception {
.startObject("context")
.startObject("location")
.field("type", "geo")
.array("precision", precisions.toArray(new Integer[precisions.size()]))
.array("precision", (Object[])precisions.toArray(new Integer[precisions.size()]))
.endObject()
.endObject().endObject()
.endObject().endObject();
Expand All @@ -185,7 +185,7 @@ public void testMappingIdempotency() throws Exception {
.startObject("context")
.startObject("location")
.field("type", "geo")
.array("precision", precisions.toArray(new Integer[precisions.size()]))
.array("precision", (Object[])precisions.toArray(new Integer[precisions.size()]))
.endObject()
.endObject().endObject()
.endObject().endObject();
Expand Down
Expand Up @@ -1713,7 +1713,9 @@ protected Collection<Class<? extends Plugin>> transportClientPlugins() {
}

/** Helper method to create list of plugins without specifying generic types. */
protected static Collection<Class<? extends Plugin>> pluginList(Class<? extends Plugin>... plugins) {
@SafeVarargs
@SuppressWarnings("varargs") // due to type erasure, the varargs type is non-reifiable, which casues this warning
protected final Collection<Class<? extends Plugin>> pluginList(Class<? extends Plugin>... plugins) {
return Arrays.asList(plugins);
}

Expand Down
1 change: 1 addition & 0 deletions plugins/analysis-icu/pom.xml
Expand Up @@ -18,6 +18,7 @@
<elasticsearch.plugin.classname>org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin</elasticsearch.plugin.classname>
<tests.rest.suite>analysis_icu</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
<xlint.options>-Xlint:-deprecation</xlint.options>
</properties>

<dependencies>
Expand Down
1 change: 1 addition & 0 deletions plugins/analysis-phonetic/pom.xml
Expand Up @@ -18,6 +18,7 @@
<elasticsearch.plugin.classname>org.elasticsearch.plugin.analysis.AnalysisPhoneticPlugin</elasticsearch.plugin.classname>
<tests.rest.suite>analysis_phonetic</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
<xlint.options>-Xlint:-rawtypes,-unchecked</xlint.options>
</properties>

<dependencies>
Expand Down
2 changes: 2 additions & 0 deletions plugins/cloud-azure/pom.xml
Expand Up @@ -30,6 +30,8 @@ governing permissions and limitations under the License. -->
<tests.jvms>1</tests.jvms>
<tests.rest.suite>cloud_azure</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
<!-- need -path because there is no resources dir... -->
<xlint.options>-Xlint:-path,-serial,-static,-unchecked</xlint.options>
</properties>

<dependencies>
Expand Down
1 change: 1 addition & 0 deletions plugins/cloud-gce/pom.xml
Expand Up @@ -31,6 +31,7 @@ governing permissions and limitations under the License. -->
<!-- currently has no unit tests -->
<tests.rest.suite>cloud_gce</tests.rest.suite>
<tests.rest.load_packaged>false</tests.rest.load_packaged>
<xlint.options>-Xlint:-rawtypes,-unchecked</xlint.options>
</properties>

<dependencies>
Expand Down
Expand Up @@ -113,7 +113,7 @@ public String[] indices() {
}

@Override
public DeleteByQueryRequest indices(String... indices) {
public DeleteByQueryRequest indices(String[] indices) {
this.indices = indices;
return this;
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public DeleteByQueryRequest source(QuerySourceBuilder sourceBuilder) {
return this;
}

public DeleteByQueryRequest source(Map querySource) {
public DeleteByQueryRequest source(Map<String,?> querySource) {
try {
XContentBuilder builder = XContentFactory.contentBuilder(Requests.CONTENT_TYPE);
builder.map(querySource);
Expand Down

0 comments on commit 9d71f07

Please sign in to comment.