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

Update checkstyle and fix violations #20909

Closed
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class PrecommitTasks {
configProperties = [
suppressions: checkstyleSuppressions
]
showViolations = true
toolVersion = "${org.elasticsearch.gradle.VersionProperties.versions['checkstyle']}"
}
for (String taskName : ['checkstyleMain', 'checkstyleTest']) {
Task task = project.tasks.findByName(taskName)
Expand Down
1 change: 1 addition & 0 deletions buildSrc/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ commonslogging = 1.1.3
commonscodec = 1.10
hamcrest = 1.3
securemock = 1.2
checkstyle = 7.1
# benchmark dependencies
jmh = 1.15
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static final class LoadGenerator {
private final BlockingQueue<List<String>> bulkQueue;
private final int bulkSize;

public LoadGenerator(Path bulkDataFile, BlockingQueue<List<String>> bulkQueue, int bulkSize) {
LoadGenerator(Path bulkDataFile, BlockingQueue<List<String>> bulkQueue, int bulkSize) {
this.bulkDataFile = bulkDataFile;
this.bulkQueue = bulkQueue;
this.bulkSize = bulkSize;
Expand Down Expand Up @@ -143,8 +143,8 @@ private static final class BulkIndexer implements Runnable {
private final BulkRequestExecutor bulkRequestExecutor;
private final SampleRecorder sampleRecorder;

public BulkIndexer(BlockingQueue<List<String>> bulkData, int warmupIterations, int measurementIterations,
SampleRecorder sampleRecorder, BulkRequestExecutor bulkRequestExecutor) {
BulkIndexer(BlockingQueue<List<String>> bulkData, int warmupIterations, int measurementIterations,
SampleRecorder sampleRecorder, BulkRequestExecutor bulkRequestExecutor) {
this.bulkData = bulkData;
this.warmupIterations = warmupIterations;
this.measurementIterations = measurementIterations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static final class RestBulkRequestExecutor implements BulkRequestExecuto
private final RestClient client;
private final String actionMetaData;

public RestBulkRequestExecutor(RestClient client, String index, String type) {
RestBulkRequestExecutor(RestClient client, String index, String type) {
this.client = client;
this.actionMetaData = String.format(Locale.ROOT, "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\" } }%n", index, type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static final class TransportBulkRequestExecutor implements BulkRequestEx
private final String indexName;
private final String typeName;

public TransportBulkRequestExecutor(TransportClient client, String indexName, String typeName) {
TransportBulkRequestExecutor(TransportClient client, String indexName, String typeName) {
this.client = client;
this.indexName = indexName;
this.typeName = typeName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static class BulkRestBuilderListener extends RestBuilderListener<BulkReq
private final RestRequest request;


public BulkRestBuilderListener(RestChannel channel, RestRequest request) {
BulkRestBuilderListener(RestChannel channel, RestRequest request) {
super(channel);
this.request = request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void testPathPrefix() throws IOException {
final HttpContext context =
httpServer.createContext("/" + pathPrefix + statusCode + uniqueContextSuffix, new ResponseHandler(statusCode));

try (final RestClient client =
try (RestClient client =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd never really thought of this but it makes sense.

RestClient.builder(new HttpHost(httpServer.getAddress().getHostString(), httpServer.getAddress().getPort()))
.setPathPrefix((randomBoolean() ? "/" : "") + pathPrefix).build()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private static final class EscapingTokenStreamToAutomaton extends TokenStreamTo
final BytesRefBuilder spare = new BytesRefBuilder();
private char sepLabel;

public EscapingTokenStreamToAutomaton(char sepLabel) {
EscapingTokenStreamToAutomaton(char sepLabel) {
this.sepLabel = sepLabel;
}

Expand Down Expand Up @@ -432,7 +432,7 @@ private static class AnalyzingComparator implements Comparator<BytesRef> {

private final boolean hasPayloads;

public AnalyzingComparator(boolean hasPayloads) {
AnalyzingComparator(boolean hasPayloads) {
this.hasPayloads = hasPayloads;
}

Expand Down Expand Up @@ -1114,7 +1114,7 @@ private static final class SurfaceFormAndPayload implements Comparable<SurfaceFo
BytesRef payload;
long weight;

public SurfaceFormAndPayload(BytesRef payload, long cost) {
SurfaceFormAndPayload(BytesRef payload, long cost) {
super();
this.payload = payload;
this.weight = cost;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/elasticsearch/ExceptionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static class GroupBy {
final String index;
final Class<? extends Throwable> causeType;

public GroupBy(Throwable t) {
GroupBy(Throwable t) {
if (t instanceof ElasticsearchException) {
final Index index = ((ElasticsearchException) t).getIndex();
if (index != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public ActionModule(boolean ingestEnabled, boolean transportClient, Settings set
static Map<String, ActionHandler<?, ?>> setupActions(List<ActionPlugin> actionPlugins) {
// Subclass NamedRegistry for easy registration
class ActionRegistry extends NamedRegistry<ActionHandler<?, ?>> {
public ActionRegistry() {
ActionRegistry() {
super("action");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static class BanLock {
private final AtomicInteger counter;
private final AtomicReference<Set<String>> nodes = new AtomicReference<>();

public BanLock(Consumer<Set<String>> finish) {
BanLock(Consumer<Set<String>> finish) {
counter = new AtomicInteger(0);
this.finish = finish;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ private BanParentTaskRequest(TaskId parentTaskId) {
this.ban = false;
}

public BanParentTaskRequest() {
BanParentTaskRequest() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public enum SnapshotIndexShardStage {

private boolean completed;

private SnapshotIndexShardStage(byte value, boolean completed) {
SnapshotIndexShardStage(byte value, boolean completed) {
this.value = value;
this.completed = completed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class GetIndexRequest extends ClusterInfoRequest<GetIndexRequest> {

public static enum Feature {
public enum Feature {
ALIASES((byte) 0, "_aliases", "_alias"),
MAPPINGS((byte) 1, "_mappings", "_mapping"),
SETTINGS((byte) 2, "_settings");
Expand All @@ -52,7 +52,7 @@ public static enum Feature {
private final String preferredName;
private final byte id;

private Feature(byte id, String... validNames) {
Feature(byte id, String... validNames) {
assert validNames != null && validNames.length > 0;
this.id = id;
this.validNames = Arrays.asList(validNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public class Response {
private final List<NodeGatewayStartedShards> responses;
private final List<FailedNodeException> failures;

public Response(ShardId shardId, List<NodeGatewayStartedShards> responses, List<FailedNodeException> failures) {
Response(ShardId shardId, List<NodeGatewayStartedShards> responses, List<FailedNodeException> failures) {
this.shardId = shardId;
this.responses = responses;
this.failures = failures;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private static final class ConstantBackoff extends BackoffPolicy {

private final int numberOfElements;

public ConstantBackoff(TimeValue delay, int numberOfElements) {
ConstantBackoff(TimeValue delay, int numberOfElements) {
assert numberOfElements >= 0;
this.delay = delay;
this.numberOfElements = numberOfElements;
Expand All @@ -188,7 +188,7 @@ private static final class ConstantBackoffIterator implements Iterator<TimeValue
private final int numberOfElements;
private int curr;

public ConstantBackoffIterator(TimeValue delay, int numberOfElements) {
ConstantBackoffIterator(TimeValue delay, int numberOfElements) {
this.delay = delay;
this.numberOfElements = numberOfElements;
}
Expand All @@ -212,7 +212,7 @@ private static final class WrappedBackoffPolicy extends BackoffPolicy {
private final BackoffPolicy delegate;
private final Runnable onBackoff;

public WrappedBackoffPolicy(BackoffPolicy delegate, Runnable onBackoff) {
WrappedBackoffPolicy(BackoffPolicy delegate, Runnable onBackoff) {
this.delegate = delegate;
this.onBackoff = onBackoff;
}
Expand All @@ -227,7 +227,7 @@ private static final class WrappedBackoffIterator implements Iterator<TimeValue>
private final Iterator<TimeValue> delegate;
private final Runnable onBackoff;

public WrappedBackoffIterator(Iterator<TimeValue> delegate, Runnable onBackoff) {
WrappedBackoffIterator(Iterator<TimeValue> delegate, Runnable onBackoff) {
this.delegate = delegate;
this.onBackoff = onBackoff;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private static class SyncBulkRequestHandler extends BulkRequestHandler {
private final BulkProcessor.Listener listener;
private final BackoffPolicy backoffPolicy;

public SyncBulkRequestHandler(Client client, BackoffPolicy backoffPolicy, BulkProcessor.Listener listener) {
SyncBulkRequestHandler(Client client, BackoffPolicy backoffPolicy, BulkProcessor.Listener listener) {
super(client);
this.backoffPolicy = backoffPolicy;
this.listener = listener;
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/elasticsearch/action/bulk/Retry.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static class AbstractRetryHandler implements ActionListener<BulkResponse> {
private volatile BulkRequest currentBulkRequest;
private volatile ScheduledFuture<?> scheduledRequestFuture;

public AbstractRetryHandler(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client, ActionListener<BulkResponse> listener) {
AbstractRetryHandler(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client, ActionListener<BulkResponse> listener) {
this.retryOnThrowable = retryOnThrowable;
this.backoff = backoffPolicy.iterator();
this.client = client;
Expand Down Expand Up @@ -211,7 +211,7 @@ public void execute(BulkRequest bulkRequest) {
}

static class AsyncRetryHandler extends AbstractRetryHandler {
public AsyncRetryHandler(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client, ActionListener<BulkResponse> listener) {
AsyncRetryHandler(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client, ActionListener<BulkResponse> listener) {
super(retryOnThrowable, backoffPolicy, client, listener);
}
}
Expand All @@ -224,7 +224,7 @@ public static SyncRetryHandler create(Class<? extends Throwable> retryOnThrowabl
return new SyncRetryHandler(retryOnThrowable, backoffPolicy, client, actionFuture);
}

public SyncRetryHandler(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client, PlainActionFuture<BulkResponse> actionFuture) {
SyncRetryHandler(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client, PlainActionFuture<BulkResponse> actionFuture) {
super(retryOnThrowable, backoffPolicy, client, actionFuture);
this.actionFuture = actionFuture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ParsedScrollId {

private final ScrollIdForNode[] context;

public ParsedScrollId(String source, String type, ScrollIdForNode[] context) {
ParsedScrollId(String source, String type, ScrollIdForNode[] context) {
this.source = source;
this.type = type;
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ScrollIdForNode {
private final String node;
private final long scrollId;

public ScrollIdForNode(String node, long scrollId) {
ScrollIdForNode(String node, long scrollId) {
this.node = node;
this.scrollId = scrollId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void writeTo(StreamOutput out) throws IOException {
static class SearchFreeContextRequest extends ScrollFreeContextRequest implements IndicesRequest {
private OriginalIndices originalIndices;

public SearchFreeContextRequest() {
SearchFreeContextRequest() {
}

SearchFreeContextRequest(SearchRequest request, long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <Response extends ActionResponse> void apply(String action, Response response, A
* filter chain. This base class should serve any action filter implementations that doesn't require
* to apply async filtering logic.
*/
public abstract static class Simple extends AbstractComponent implements ActionFilter {
abstract class Simple extends AbstractComponent implements ActionFilter {

protected Simple(Settings settings) {
super(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,10 @@ class NodeResponse extends TransportResponse {
protected List<BroadcastShardOperationFailedException> exceptions;
protected List<ShardOperationResult> results;

public NodeResponse() {
NodeResponse() {
}

public NodeResponse(String nodeId,
NodeResponse(String nodeId,
int totalShards,
List<ShardOperationResult> results,
List<BroadcastShardOperationFailedException> exceptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class WritePrimaryResult extends PrimaryResult implements RespondingWriteResult
boolean finishedAsyncActions;
ActionListener<Response> listener = null;

public WritePrimaryResult(Request request, Response finalResponse,
WritePrimaryResult(Request request, Response finalResponse,
@Nullable Translog.Location location,
IndexShard indexShard) {
super(request, finalResponse);
Expand Down Expand Up @@ -160,7 +160,7 @@ class WriteReplicaResult extends ReplicaResult implements RespondingWriteResult
boolean finishedAsyncActions;
private ActionListener<TransportResponse.Empty> listener;

public WriteReplicaResult(IndexShard indexShard, ReplicatedWriteRequest<?> request, Translog.Location location) {
WriteReplicaResult(IndexShard indexShard, ReplicatedWriteRequest<?> request, Translog.Location location) {
new AsyncAfterWriteAction(indexShard, request, location, this, logger).run();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ private class NodeTasksResponse extends TransportResponse {
protected List<TaskOperationFailure> exceptions;
protected List<TaskResponse> results;

public NodeTasksResponse() {
NodeTasksResponse() {
}

public NodeTasksResponse(String nodeId,
NodeTasksResponse(String nodeId,
List<TaskResponse> results,
List<TaskOperationFailure> exceptions) {
this.nodeId = nodeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private final class TermVector extends Terms {
private long sumDocFreq;
private int docCount;

public TermVector(BytesReference termVectors, long readOffset) throws IOException {
TermVector(BytesReference termVectors, long readOffset) throws IOException {
this.perFieldTermVectorInput = termVectors.streamInput();
this.readOffset = readOffset;
reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeLong(version);
}

public static enum Flag {
public enum Flag {
// Do not change the order of these flags we use
// the ordinal for encoding! Only append to the end!
Positions, Offsets, Payloads, FieldStatistics, TermStatistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ long getMaxHeapSize() {

static class OsXFileDescriptorCheck extends FileDescriptorCheck {

public OsXFileDescriptorCheck() {
OsXFileDescriptorCheck() {
// see constant OPEN_MAX defined in
// /usr/include/sys/syslimits.h on OS X and its use in JVM
// initialization in int os:init_2(void) defined in the JVM
Expand Down Expand Up @@ -285,7 +285,7 @@ static class MlockallCheck implements Check {

private final boolean mlockallSet;

public MlockallCheck(final boolean mlockAllSet) {
MlockallCheck(final boolean mlockAllSet) {
this.mlockallSet = mlockAllSet;
}

Expand Down Expand Up @@ -386,7 +386,7 @@ long getMaxMapCount() {
// visible for testing
long getMaxMapCount(Logger logger) {
final Path path = getProcSysVmMaxMapCountPath();
try (final BufferedReader bufferedReader = getBufferedReader(path)) {
try (BufferedReader bufferedReader = getBufferedReader(path)) {
final String rawProcSysVmMaxMapCount = readProcSysVmMaxMapCount(bufferedReader);
if (rawProcSysVmMaxMapCount != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class ESPolicy extends Policy {
final PermissionCollection dynamic;
final Map<String,Policy> plugins;

public ESPolicy(PermissionCollection dynamic, Map<String,Policy> plugins, boolean filterBadDefaults) {
ESPolicy(PermissionCollection dynamic, Map<String,Policy> plugins, boolean filterBadDefaults) {
this.template = Security.readPolicy(getClass().getResource(POLICY_RESOURCE), JarHell.parseClassPath());
this.untrusted = Security.readPolicy(getClass().getResource(UNTRUSTED_RESOURCE), new URL[0]);
if (filterBadDefaults) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class NativeHandlerCallback implements StdCallLibrary.StdCallCallback {

private final ConsoleCtrlHandler handler;

public NativeHandlerCallback(ConsoleCtrlHandler handler) {
NativeHandlerCallback(ConsoleCtrlHandler handler) {
this.handler = handler;
}

Expand Down Expand Up @@ -155,11 +155,11 @@ protected List<String> getFieldOrder() {

public static class SizeT extends IntegerType {

public SizeT() {
SizeT() {
this(0);
}

public SizeT(long value) {
SizeT(long value) {
super(Native.SIZE_T_SIZE, value);
}

Expand Down
Loading