Skip to content

Commit 37a24d5

Browse files
vamuzumdelasticmachine
authored andcommitted
Enable compiler warnings in xpack core plugin project (#66899)
Co-authored-by: Elastic Machine <[email protected]>
1 parent dc7ac98 commit 37a24d5

File tree

54 files changed

+124
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+124
-68
lines changed

server/src/main/java/org/elasticsearch/common/util/CollectionUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ public static <E> ArrayList<E> iterableAsArrayList(Iterable<? extends E> element
284284
}
285285
}
286286

287+
@SafeVarargs
288+
@SuppressWarnings("varargs")
287289
public static <E> ArrayList<E> arrayAsArrayList(E... elements) {
288290
if (elements == null) {
289291
throw new NullPointerException("elements");

test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,15 @@ public static int randomInt(int max) {
762762
}
763763

764764
/** Pick a random object from the given array. The array must not be empty. */
765+
@SafeVarargs
766+
@SuppressWarnings("varargs")
765767
public static <T> T randomFrom(T... array) {
766768
return randomFrom(random(), array);
767769
}
768770

769771
/** Pick a random object from the given array. The array must not be empty. */
772+
@SafeVarargs
773+
@SuppressWarnings("varargs")
770774
public static <T> T randomFrom(Random random, T... array) {
771775
return RandomPicks.randomFrom(random, array);
772776
}

x-pack/plugin/core/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ tasks.named('forbiddenApisMain').configure {
106106
signaturesFiles += files('forbidden/hasher-signatures.txt')
107107
}
108108

109-
tasks.withType(JavaCompile).configureEach {
110-
options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
111-
}
112109

113110
// make LicenseSigner available for testing signed licenses
114111
sourceSets.test.resources {

x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/search/PointInTimeIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ public void testPITTiebreak() throws Exception {
427427
}
428428
}
429429

430+
@SuppressWarnings({"rawtypes","unchecked"})
430431
private void assertPagination(PointInTimeBuilder pit, int expectedNumDocs, int size, SortBuilder<?>... sorts) throws Exception {
431432
Set<String> seen = new HashSet<>();
432433
SearchRequestBuilder builder = client().prepareSearch()

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractGetResourcesResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public boolean equals(Object obj) {
7171
if (obj instanceof AbstractGetResourcesResponse == false) {
7272
return false;
7373
}
74-
AbstractGetResourcesResponse other = (AbstractGetResourcesResponse) obj;
74+
AbstractGetResourcesResponse<?> other = (AbstractGetResourcesResponse<?>) obj;
7575
return Objects.equals(resources, other.resources);
7676
}
7777

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/EvaluateDataFrameAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static class Request extends ActionRequest implements ToXContentObject {
5454
private static final ParseField QUERY = new ParseField("query");
5555
private static final ParseField EVALUATION = new ParseField("evaluation");
5656

57+
@SuppressWarnings({ "unchecked"})
5758
private static final ConstructingObjectParser<Request, Void> PARSER = new ConstructingObjectParser<>(
5859
NAME,
5960
a -> new Request((List<String>) a[0], (QueryProvider) a[1], (Evaluation) a[2]));

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static class Response extends ActionResponse implements ToXContentObject
3737
public static final ParseField FIELD_SELECTION = new ParseField("field_selection");
3838
public static final ParseField MEMORY_ESTIMATION = new ParseField("memory_estimation");
3939

40+
@SuppressWarnings({ "unchecked"})
4041
static final ConstructingObjectParser<Response, Void> PARSER =
4142
new ConstructingObjectParser<>(
4243
TYPE.getPreferredName(),

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsSource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class DataFrameAnalyticsSource implements Writeable, ToXContentObject {
4444
public static final ParseField QUERY = new ParseField("query");
4545
public static final ParseField _SOURCE = new ParseField("_source");
4646

47+
@SuppressWarnings({ "unchecked"})
4748
public static ConstructingObjectParser<DataFrameAnalyticsSource, Void> createParser(boolean ignoreUnknownFields) {
4849
ConstructingObjectParser<DataFrameAnalyticsSource, Void> parser = new ConstructingObjectParser<>("data_frame_analytics_source",
4950
ignoreUnknownFields, a -> new DataFrameAnalyticsSource(

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/ConfusionMatrix.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class ConfusionMatrix extends AbstractConfusionMatrixMetric {
2828

2929
public static final ParseField NAME = new ParseField("confusion_matrix");
3030

31+
@SuppressWarnings("unchecked")
3132
private static final ConstructingObjectParser<ConfusionMatrix, Void> PARSER = new ConstructingObjectParser<>(NAME.getPreferredName(),
3233
a -> new ConfusionMatrix((List<Double>) a[0]));
3334

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/OutlierDetection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class OutlierDetection implements Evaluation {
3838

3939
private static final ParseField METRICS = new ParseField("metrics");
4040

41+
@SuppressWarnings("unchecked")
4142
public static final ConstructingObjectParser<OutlierDetection, Void> PARSER = new ConstructingObjectParser<>(
4243
NAME.getPreferredName(), a -> new OutlierDetection((String) a[0], (String) a[1], (List<EvaluationMetric>) a[2]));
4344

0 commit comments

Comments
 (0)