Skip to content

Commit 679b0e1

Browse files
committed
Enforce 140 char line lengths for packages action.bulk/delete/explain/get/index (#34885)
part of #34884
1 parent 6f2c7ce commit 679b0e1

File tree

16 files changed

+99
-73
lines changed

16 files changed

+99
-73
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,6 @@
8282
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]tasks[/\\]PendingClusterTasksAction.java" checks="LineLength" />
8383
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]tasks[/\\]PendingClusterTasksRequestBuilder.java" checks="LineLength" />
8484
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]tasks[/\\]TransportPendingClusterTasksAction.java" checks="LineLength" />
85-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BackoffPolicy.java" checks="LineLength" />
86-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkProcessor.java" checks="LineLength" />
87-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkRequest.java" checks="LineLength" />
88-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkResponse.java" checks="LineLength" />
89-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]Retry.java" checks="LineLength" />
90-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]TransportBulkAction.java" checks="LineLength" />
91-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]TransportShardBulkAction.java" checks="LineLength" />
92-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]delete[/\\]DeleteRequest.java" checks="LineLength" />
93-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]explain[/\\]TransportExplainAction.java" checks="LineLength" />
94-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]GetRequest.java" checks="LineLength" />
95-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]MultiGetRequest.java" checks="LineLength" />
96-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]TransportGetAction.java" checks="LineLength" />
97-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]TransportShardMultiGetAction.java" checks="LineLength" />
98-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]index[/\\]IndexRequest.java" checks="LineLength" />
9985
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]MultiSearchRequestBuilder.java" checks="LineLength" />
10086
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchPhaseController.java" checks="LineLength" />
10187
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]ShardSearchFailure.java" checks="LineLength" />
@@ -267,9 +253,6 @@
267253
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]SnapshotBlocksIT.java" checks="LineLength" />
268254
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]state[/\\]ClusterStateRequestTests.java" checks="LineLength" />
269255
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]stats[/\\]ClusterStatsIT.java" checks="LineLength" />
270-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkRequestTests.java" checks="LineLength" />
271-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]RetryTests.java" checks="LineLength" />
272-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]MultiGetShardRequestTests.java" checks="LineLength" />
273256
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchRequestBuilderTests.java" checks="LineLength" />
274257
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]TransportActionFilterChainTests.java" checks="LineLength" />
275258
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]WaitActiveShardCountIT.java" checks="LineLength" />

server/src/main/java/org/elasticsearch/action/bulk/BackoffPolicy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
* semantics:
3535
*
3636
* <ul>
37-
* <li><code>#hasNext()</code> determines whether the progression has more elements. Return <code>true</code> for infinite progressions</li>
37+
* <li><code>#hasNext()</code> determines whether the progression has more elements. Return <code>true</code> for infinite progressions
38+
* </li>
3839
* <li><code>#next()</code> determines the next element in the progression, i.e. the next wait time period</li>
3940
* </ul>
4041
*

server/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,13 @@ public void close() {
219219
* Closes the processor. If flushing by time is enabled, then it's shutdown. Any remaining bulk actions are flushed.
220220
* <p>
221221
* If concurrent requests are not enabled, returns {@code true} immediately.
222-
* If concurrent requests are enabled, waits for up to the specified timeout for all bulk requests to complete then returns {@code true},
222+
* If concurrent requests are enabled, waits for up to the specified timeout for all bulk requests to complete then returns {@code true}
223223
* If the specified waiting time elapses before all bulk requests complete, {@code false} is returned.
224224
*
225225
* @param timeout The maximum time to wait for the bulk requests to complete
226226
* @param unit The time unit of the {@code timeout} argument
227-
* @return {@code true} if all bulk requests completed and {@code false} if the waiting time elapsed before all the bulk requests completed
227+
* @return {@code true} if all bulk requests completed and {@code false} if the waiting time elapsed before all the bulk requests
228+
* completed
228229
* @throws InterruptedException If the current thread is interrupted
229230
*/
230231
public synchronized boolean awaitClose(long timeout, TimeUnit unit) throws InterruptedException {
@@ -300,7 +301,8 @@ public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nu
300301
* Adds the data from the bytes to be processed by the bulk processor
301302
*/
302303
public synchronized BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType,
303-
@Nullable String defaultPipeline, @Nullable Object payload, XContentType xContentType) throws Exception {
304+
@Nullable String defaultPipeline, @Nullable Object payload,
305+
XContentType xContentType) throws Exception {
304306
bulkRequest.add(data, defaultIndex, defaultType, null, null, null, defaultPipeline, payload, true, xContentType);
305307
executeIfNeeded();
306308
return this;

server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,33 +376,39 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null
376376
} else if (PIPELINE.match(currentFieldName, parser.getDeprecationHandler())) {
377377
pipeline = parser.text();
378378
} else if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {
379-
throw new IllegalArgumentException("Action/metadata line [" + line + "] contains a simple value for parameter [fields] while a list is expected");
379+
throw new IllegalArgumentException("Action/metadata line [" + line + "] contains a simple value for"
380+
+ " parameter [fields] while a list is expected");
380381
} else if (SOURCE.match(currentFieldName, parser.getDeprecationHandler())) {
381382
fetchSourceContext = FetchSourceContext.fromXContent(parser);
382383
} else {
383-
throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter [" + currentFieldName + "]");
384+
throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter ["
385+
+ currentFieldName + "]");
384386
}
385387
} else if (token == XContentParser.Token.START_ARRAY) {
386388
if (FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {
387389
DEPRECATION_LOGGER.deprecated("Deprecated field [fields] used, expected [_source] instead");
388390
List<Object> values = parser.list();
389391
fields = values.toArray(new String[values.size()]);
390392
} else {
391-
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]");
393+
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple "
394+
+ "value for field [" + currentFieldName + "] but found [" + token + "]");
392395
}
393-
} else if (token == XContentParser.Token.START_OBJECT && SOURCE.match(currentFieldName, parser.getDeprecationHandler())) {
396+
} else if (token == XContentParser.Token.START_OBJECT && SOURCE.match(currentFieldName,
397+
parser.getDeprecationHandler())) {
394398
fetchSourceContext = FetchSourceContext.fromXContent(parser);
395399
} else if (token != XContentParser.Token.VALUE_NULL) {
396-
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]");
400+
throw new IllegalArgumentException("Malformed action/metadata line [" + line
401+
+ "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]");
397402
}
398403
}
399404
} else if (token != XContentParser.Token.END_OBJECT) {
400-
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected " + XContentParser.Token.START_OBJECT
401-
+ " or " + XContentParser.Token.END_OBJECT + " but found [" + token + "]");
405+
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected "
406+
+ XContentParser.Token.START_OBJECT + " or " + XContentParser.Token.END_OBJECT + " but found [" + token + "]");
402407
}
403408

404409
if ("delete".equals(action)) {
405-
add(new DeleteRequest(index, type, id).routing(routing).parent(parent).version(version).versionType(versionType), payload);
410+
add(new DeleteRequest(index, type, id).routing(routing).parent(parent).version(version)
411+
.versionType(versionType), payload);
406412
} else {
407413
nextMarker = findNextMarker(marker, from, data, length);
408414
if (nextMarker == -1) {
@@ -414,21 +420,21 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null
414420
// of index request.
415421
if ("index".equals(action)) {
416422
if (opType == null) {
417-
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).version(version).versionType(versionType)
418-
.setPipeline(pipeline)
423+
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).version(version)
424+
.versionType(versionType).setPipeline(pipeline)
419425
.source(sliceTrimmingCarriageReturn(data, from, nextMarker,xContentType), xContentType), payload);
420426
} else {
421-
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).version(version).versionType(versionType)
422-
.create("create".equals(opType)).setPipeline(pipeline)
427+
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).version(version)
428+
.versionType(versionType).create("create".equals(opType)).setPipeline(pipeline)
423429
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType), payload);
424430
}
425431
} else if ("create".equals(action)) {
426-
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).version(version).versionType(versionType)
427-
.create(true).setPipeline(pipeline)
432+
internalAdd(new IndexRequest(index, type, id).routing(routing).parent(parent).version(version)
433+
.versionType(versionType).create(true).setPipeline(pipeline)
428434
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType), payload);
429435
} else if ("update".equals(action)) {
430-
UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).parent(parent).retryOnConflict(retryOnConflict)
431-
.version(version).versionType(versionType)
436+
UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).parent(parent)
437+
.retryOnConflict(retryOnConflict).version(version).versionType(versionType)
432438
.routing(routing)
433439
.parent(parent);
434440
// EMPTY is safe here because we never call namedObject

server/src/main/java/org/elasticsearch/action/bulk/BulkResponse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public String buildFailureMessage() {
109109
BulkItemResponse response = responses[i];
110110
if (response.isFailed()) {
111111
sb.append("\n[").append(i)
112-
.append("]: index [").append(response.getIndex()).append("], type [").append(response.getType()).append("], id [").append(response.getId())
112+
.append("]: index [").append(response.getIndex()).append("], type [")
113+
.append(response.getType()).append("], id [").append(response.getId())
113114
.append("], message [").append(response.getFailureMessage()).append("]");
114115
}
115116
}

0 commit comments

Comments
 (0)