Skip to content

Commit

Permalink
Remove unnecessary warning supressions (#32250)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Büscher committed Jul 23, 2018
1 parent 4b3284f commit ff87b7a
Show file tree
Hide file tree
Showing 87 changed files with 64 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import io.netty.util.ThreadDeathWatcher;
import io.netty.util.concurrent.GlobalEventExecutor;

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.network.NetworkModule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ private static class TestChannelFactory extends ChannelFactory<NioServerSocketCh
super(rawChannelFactory);
}

@SuppressWarnings("unchecked")
@Override
public NioSocketChannel createChannel(NioSelector selector, SocketChannel channel) throws IOException {
NioSocketChannel nioSocketChannel = new NioSocketChannel(channel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public void testHandleAcceptCallsChannelFactory() throws IOException {
verify(channelFactory, times(2)).acceptNioChannel(same(serverContext), same(selectorSupplier));
}

@SuppressWarnings("unchecked")
public void testHandleAcceptCallsServerAcceptCallback() throws IOException {
NioSocketChannel childChannel = new NioSocketChannel(mock(SocketChannel.class));
SocketChannelContext childContext = mock(SocketChannelContext.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ public void testCloseClosesWriteProducer() throws IOException {
}
}

@SuppressWarnings("unchecked")
public void testCloseClosesChannelBuffer() throws IOException {
try (SocketChannel realChannel = SocketChannel.open()) {
when(channel.getRawChannel()).thenReturn(realChannel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class MultiPassStats {
this.fieldBKey = fieldBName;
}

@SuppressWarnings("unchecked")
void computeStats(final List<Double> fieldA, final List<Double> fieldB) {
// set count
count = fieldA.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public void testFieldMissing() {
assertThat(exception.getMessage(), equalTo("field [field] not present as part of path [field]"));
}

@SuppressWarnings("unchecked")
public void testAddToRoot() throws Exception {
String processorTag = randomAlphaOfLength(3);
String randomTargetField = randomAlphaOfLength(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class InitializerTests extends ScriptTestCase {

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes"})
public void testArrayInitializers() {
int[] ints = (int[])exec("new int[] {}");

Expand Down Expand Up @@ -59,7 +59,7 @@ public void testArrayInitializers() {
assertEquals("aaaaaa", objects[3]);
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes"})
public void testListInitializers() {
List list = (List)exec("[]");

Expand Down Expand Up @@ -91,7 +91,7 @@ public void testListInitializers() {
assertEquals("aaaaaa", list.get(3));
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes"})
public void testMapInitializers() {
Map map = (Map)exec("[:]");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client
}

@Override
@SuppressWarnings("unchecked")
protected UpdateByQueryRequest buildRequest(RestRequest request) throws IOException {
/*
* Passing the search request through UpdateByQueryRequest first allows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ protected MockTransportService build(Settings settings, Version version, Cluster
@Override
protected void closeConnectionChannel(Transport transport, Transport.Connection connection) throws IOException {
final Netty4Transport t = (Netty4Transport) transport;
@SuppressWarnings("unchecked")
final TcpTransport.NodeChannels channels = (TcpTransport.NodeChannels) connection;
CloseableChannel.closeChannels(channels.getChannels().subList(0, randomIntBetween(1, channels.getChannels().size())), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpUtil;
import io.netty.handler.codec.http.HttpVersion;

import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
Expand Down Expand Up @@ -89,7 +90,6 @@ public class HttpReadWriteHandlerTests extends ESTestCase {
private final ResponseDecoder responseDecoder = new ResponseDecoder();

@Before
@SuppressWarnings("unchecked")
public void setMocks() {
transport = mock(NioHttpServerTransport.class);
Settings settings = Settings.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ protected MockTransportService build(Settings settings, Version version, Cluster

@Override
protected void closeConnectionChannel(Transport transport, Transport.Connection connection) throws IOException {
@SuppressWarnings("unchecked")
TcpTransport.NodeChannels channels = (TcpTransport.NodeChannels) connection;
CloseableChannel.closeChannels(channels.getChannels().subList(0, randomIntBetween(1, channels.getChannels().size())), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class ClusterGetSettingsResponse extends ActionResponse implements ToXCon
static final String TRANSIENT_FIELD = "transient";
static final String DEFAULTS_FIELD = "defaults";

@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<ClusterGetSettingsResponse, Void> PARSER =
new ConstructingObjectParser<>(
"cluster_get_settings_response",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class QueryExplanation implements Streamable, ToXContentFragment {

public static final int RANDOM_SHARD = -1;

@SuppressWarnings("unchecked")
static ConstructingObjectParser<QueryExplanation, Void> PARSER = new ConstructingObjectParser<>(
"query_explanation",
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public String getSourceAsString() {
/**
* The source of the document (As a map).
*/
@SuppressWarnings({"unchecked"})
public Map<String, Object> getSourceAsMap() throws ElasticsearchParseException {
return getResult.sourceAsMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import java.io.IOException;

import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;

public class SimulateProcessorResult implements Writeable, ToXContentObject {

Expand All @@ -42,7 +42,6 @@ public class SimulateProcessorResult implements Writeable, ToXContentObject {
private final WriteableIngestDocument ingestDocument;
private final Exception failure;

@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<ElasticsearchException, Void> IGNORED_ERROR_PARSER =
new ConstructingObjectParser<>(
"ignored_error_parser",
Expand All @@ -57,7 +56,6 @@ public class SimulateProcessorResult implements Writeable, ToXContentObject {
);
}

@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<SimulateProcessorResult, Void> PARSER =
new ConstructingObjectParser<>(
"simulate_processor_result",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ final class WriteableIngestDocument implements Writeable, ToXContentFragment {
);
}

@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<WriteableIngestDocument, Void> PARSER =
new ConstructingObjectParser<>(
"writeable_ingest_document",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.action.support;

import com.carrotsearch.hppc.cursors.IntObjectCursor;

import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
Expand Down Expand Up @@ -205,7 +206,7 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
@SuppressWarnings("unchecked") ActiveShardCount that = (ActiveShardCount) o;
ActiveShardCount that = (ActiveShardCount) o;
return value == that.value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public RequestBuilder setWaitForActiveShards(ActiveShardCount waitForActiveShard
* shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)}
* to get the ActiveShardCount.
*/
@SuppressWarnings("unchecked")
public RequestBuilder setWaitForActiveShards(final int waitForActiveShards) {
return setWaitForActiveShards(ActiveShardCount.from(waitForActiveShards));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.cluster;

import com.carrotsearch.hppc.cursors.ObjectObjectCursor;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterState.Custom;
import org.elasticsearch.common.collect.ImmutableOpenMap;
Expand Down Expand Up @@ -165,7 +166,7 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
@SuppressWarnings("unchecked") Entry entry = (Entry) o;
Entry entry = (Entry) o;
return snapshot.equals(entry.snapshot) &&
state == entry.state &&
indices.equals(entry.indices) &&
Expand Down Expand Up @@ -291,7 +292,7 @@ public boolean equals(Object o) {
return false;
}

@SuppressWarnings("unchecked") ShardRestoreStatus status = (ShardRestoreStatus) o;
ShardRestoreStatus status = (ShardRestoreStatus) o;
return state == status.state &&
Objects.equals(nodeId, status.nodeId) &&
Objects.equals(reason, status.reason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public void writeTo(final StreamOutput out) throws IOException {
}

@Override
@SuppressWarnings("unchecked")
public Diff<MetaData.Custom> diff(final MetaData.Custom previous) {
return new IndexGraveyardDiff((IndexGraveyard) previous, this);
}
Expand Down Expand Up @@ -321,7 +320,7 @@ public void writeTo(final StreamOutput out) throws IOException {

@Override
public IndexGraveyard apply(final MetaData.Custom previous) {
@SuppressWarnings("unchecked") final IndexGraveyard old = (IndexGraveyard) previous;
final IndexGraveyard old = (IndexGraveyard) previous;
if (removedCount > old.tombstones.size()) {
throw new IllegalStateException("IndexGraveyardDiff cannot remove [" + removedCount + "] entries from [" +
old.tombstones.size() + "] tombstones.");
Expand Down Expand Up @@ -416,7 +415,7 @@ public boolean equals(final Object other) {
if (other == null || getClass() != other.getClass()) {
return false;
}
@SuppressWarnings("unchecked") Tombstone that = (Tombstone) other;
Tombstone that = (Tombstone) other;
return index.equals(that.index) && deleteDateInMillis == that.deleteDateInMillis;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.rollover.RolloverInfo;
import org.elasticsearch.action.support.ActiveShardCount;
Expand Down Expand Up @@ -685,7 +686,6 @@ public Custom read(StreamInput in, String key) throws IOException {
return lookupPrototypeSafe(key).readFrom(in);
}

@SuppressWarnings("unchecked")
@Override
public Diff<Custom> readDiff(StreamInput in, String key) throws IOException {
return lookupPrototypeSafe(key).readDiffFrom(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ public IndexTemplateMetaData build() {
aliases.build(), customs.build());
}

@SuppressWarnings("unchecked")
public static void toXContent(IndexTemplateMetaData indexTemplateMetaData, XContentBuilder builder, ToXContent.Params params)
throws IOException {
builder.startObject(indexTemplateMetaData.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;

import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.action.AliasesRequest;
Expand Down Expand Up @@ -169,7 +170,6 @@ public interface Custom extends NamedDiffable<Custom>, ToXContentFragment, Clust

private final SortedMap<String, AliasOrIndex> aliasAndIndexLookup;

@SuppressWarnings("unchecked")
MetaData(String clusterUUID, long version, Settings transientSettings, Settings persistentSettings,
ImmutableOpenMap<String, IndexMetaData> indices, ImmutableOpenMap<String, IndexTemplateMetaData> templates,
ImmutableOpenMap<String, Custom> customs, String[] allIndices, String[] allOpenIndices, String[] allClosedIndices,
Expand Down Expand Up @@ -1000,7 +1000,7 @@ public Builder indexGraveyard(final IndexGraveyard indexGraveyard) {
}

public IndexGraveyard indexGraveyard() {
@SuppressWarnings("unchecked") IndexGraveyard graveyard = (IndexGraveyard) getCustom(IndexGraveyard.TYPE);
IndexGraveyard graveyard = (IndexGraveyard) getCustom(IndexGraveyard.TYPE);
return graveyard;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public boolean equals(Object o) {
return false;
}

@SuppressWarnings("unchecked") SnapshotRecoverySource that = (SnapshotRecoverySource) o;
SnapshotRecoverySource that = (SnapshotRecoverySource) o;
return snapshot.equals(that.snapshot) && index.equals(that.index) && version.equals(that.version);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public boolean equals(Object other) {
if (other == null || other instanceof AbstractAllocationDecision == false) {
return false;
}
@SuppressWarnings("unchecked") AbstractAllocationDecision that = (AbstractAllocationDecision) other;
AbstractAllocationDecision that = (AbstractAllocationDecision) other;
return Objects.equals(targetNode, that.targetNode) && Objects.equals(nodeDecisions, that.nodeDecisions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public boolean equals(Object other) {
if (other instanceof AllocateUnassignedDecision == false) {
return false;
}
@SuppressWarnings("unchecked") AllocateUnassignedDecision that = (AllocateUnassignedDecision) other;
AllocateUnassignedDecision that = (AllocateUnassignedDecision) other;
return Objects.equals(allocationStatus, that.allocationStatus)
&& Objects.equals(allocationId, that.allocationId)
&& reuseStore == that.reuseStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public boolean equals(Object other) {
if (other instanceof MoveDecision == false) {
return false;
}
@SuppressWarnings("unchecked") MoveDecision that = (MoveDecision) other;
MoveDecision that = (MoveDecision) other;
return Objects.equals(allocationDecision, that.allocationDecision)
&& Objects.equals(canRemainDecision, that.canRemainDecision)
&& Objects.equals(clusterRebalanceDecision, that.clusterRebalanceDecision)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void removeLifecycleListener(LifecycleListener listener) {
listeners.remove(listener);
}

@SuppressWarnings({"unchecked"})
@Override
public void start() {
if (!lifecycle.canMoveToStarted()) {
Expand All @@ -72,7 +71,6 @@ public void start() {

protected abstract void doStart();

@SuppressWarnings({"unchecked"})
@Override
public void stop() {
if (!lifecycle.canMoveToStopped()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class ConstructorInjectorStore {
private final FailableCache<TypeLiteral<?>, ConstructorInjector<?>> cache
= new FailableCache<TypeLiteral<?>, ConstructorInjector<?>>() {
@Override
@SuppressWarnings("unchecked")
protected ConstructorInjector<?> create(TypeLiteral<?> type, Errors errors)
throws ErrorsException {
return createConstructor(type, errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public String toString() {
},
new TypeConverter() {
@Override
@SuppressWarnings("unchecked")
public Object convert(String value, TypeLiteral<?> toType) {
try {
return Class.forName(value);
Expand All @@ -128,7 +127,6 @@ private <T> void convertToPrimitiveType(Class<T> primitiveType, final Class<T> w

TypeConverter typeConverter = new TypeConverter() {
@Override
@SuppressWarnings("unchecked")
public Object convert(String value, TypeLiteral<?> toType) {
try {
return parser.invoke(null, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class AssistedConstructor<T> {
private final ParameterListKey assistedParameters;
private final List<Parameter> allParameters;

@SuppressWarnings("unchecked")
AssistedConstructor(Constructor<T> constructor, List<TypeLiteral<?>> parameterTypes) {
this.constructor = constructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public T get() {

try {
// We know this cast is safe because T is the method's return type.
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
@SuppressWarnings({"unchecked"})
T result = (T) method.invoke(instance, parameters);
return result;
} catch (IllegalAccessException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ private RealMultibinder(Binder binder, TypeLiteral<T> elementType,
}

@Override
@SuppressWarnings("unchecked")
public void configure(Binder binder) {
checkConfiguration(!isInitialized(), "Multibinder was already initialized");

Expand Down
Loading

0 comments on commit ff87b7a

Please sign in to comment.