From 5b65a002a0feb6192cff7849ccd7ac7bbe2d27a8 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 30 Dec 2020 18:50:58 -0800 Subject: [PATCH 01/15] Added unchecked suppression, resolved some rawtypes --- .../stats/classification/ValidationLoss.java | 2 +- x-pack/plugin/core/build.gradle | 2 -- .../action/AbstractGetResourcesResponse.java | 2 +- .../ml/action/EvaluateDataFrameAction.java | 1 + .../ExplainDataFrameAnalyticsAction.java | 1 + .../dataframe/DataFrameAnalyticsSource.java | 1 + .../outlierdetection/ConfusionMatrix.java | 1 + .../outlierdetection/OutlierDetection.java | 1 + .../outlierdetection/Precision.java | 1 + .../evaluation/outlierdetection/Recall.java | 1 + .../stats/classification/ValidationLoss.java | 1 + .../ml/dataframe/stats/common/FoldValues.java | 1 + .../stats/regression/ValidationLoss.java | 1 + .../xpack/core/ml/job/config/RuleScope.java | 3 ++- .../xpack/core/ml/job/results/Influence.java | 1 + .../core/rollup/job/RollupJobStatus.java | 1 + .../xpack/core/security/SecurityContext.java | 1 + .../xpack/core/ssl/CertParsingUtils.java | 5 ++-- .../core/watcher/actions/ActionWrapper.java | 13 +++++----- .../watcher/actions/ExecutableAction.java | 2 +- .../watcher/client/WatchSourceBuilder.java | 22 ++++++++-------- .../core/watcher/history/WatchRecord.java | 10 +++++--- .../core/watcher/support/WatcherUtils.java | 1 + .../support/xcontent/XContentSource.java | 8 +++--- .../watcher/transform/TransformRegistry.java | 25 ++++++++++++------- .../transform/chain/ChainTransform.java | 4 +-- .../chain/ChainTransformFactory.java | 1 + .../chain/ExecutableChainTransform.java | 7 +++++- .../xpack/core/watcher/watch/Watch.java | 13 ++++++---- 29 files changed, 84 insertions(+), 49 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java index a552f5d85e124..19dce73406805 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java @@ -33,7 +33,7 @@ public class ValidationLoss implements ToXContentObject { public static final ParseField LOSS_TYPE = new ParseField("loss_type"); public static final ParseField FOLD_VALUES = new ParseField("fold_values"); - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked"}) public static ConstructingObjectParser PARSER = new ConstructingObjectParser<>("classification_validation_loss", true, a -> new ValidationLoss((String) a[0], (List) a[1])); diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index 91dc2b1089c1c..8314056a46629 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -103,8 +103,6 @@ tasks.named('forbiddenApisMain').configure { signaturesFiles += files('forbidden/hasher-signatures.txt') } -compileJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked" -compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked" // make LicenseSigner available for testing signed licenses sourceSets.test.resources { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractGetResourcesResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractGetResourcesResponse.java index 56e5428476419..efd5fbc628584 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractGetResourcesResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractGetResourcesResponse.java @@ -70,7 +70,7 @@ public boolean equals(Object obj) { if (obj instanceof AbstractGetResourcesResponse == false) { return false; } - AbstractGetResourcesResponse other = (AbstractGetResourcesResponse) obj; + AbstractGetResourcesResponse other = (AbstractGetResourcesResponse) obj; return Objects.equals(resources, other.resources); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/EvaluateDataFrameAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/EvaluateDataFrameAction.java index 6362be67d7822..5e5be03d30ecd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/EvaluateDataFrameAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/EvaluateDataFrameAction.java @@ -50,6 +50,7 @@ public static class Request extends ActionRequest implements ToXContentObject { private static final ParseField QUERY = new ParseField("query"); private static final ParseField EVALUATION = new ParseField("evaluation"); + @SuppressWarnings({ "unchecked"}) private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( NAME, a -> new Request((List) a[0], (QueryProvider) a[1], (Evaluation) a[2])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java index 46888ea27a7a9..195e673b2a94f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ExplainDataFrameAnalyticsAction.java @@ -36,6 +36,7 @@ public static class Response extends ActionResponse implements ToXContentObject public static final ParseField FIELD_SELECTION = new ParseField("field_selection"); public static final ParseField MEMORY_ESTIMATION = new ParseField("memory_estimation"); + @SuppressWarnings({ "unchecked"}) static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( TYPE.getPreferredName(), diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsSource.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsSource.java index ac78f3ebfe248..582f7080127d6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsSource.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/DataFrameAnalyticsSource.java @@ -39,6 +39,7 @@ public class DataFrameAnalyticsSource implements Writeable, ToXContentObject { public static final ParseField QUERY = new ParseField("query"); public static final ParseField _SOURCE = new ParseField("_source"); + @SuppressWarnings({ "unchecked"}) public static ConstructingObjectParser createParser(boolean ignoreUnknownFields) { ConstructingObjectParser parser = new ConstructingObjectParser<>("data_frame_analytics_source", ignoreUnknownFields, a -> new DataFrameAnalyticsSource( diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/ConfusionMatrix.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/ConfusionMatrix.java index 294f8fff2436e..393df0d9d1a0f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/ConfusionMatrix.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/ConfusionMatrix.java @@ -27,6 +27,7 @@ public class ConfusionMatrix extends AbstractConfusionMatrixMetric { public static final ParseField NAME = new ParseField("confusion_matrix"); + @SuppressWarnings("unchecked") private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(NAME.getPreferredName(), a -> new ConfusionMatrix((List) a[0])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/OutlierDetection.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/OutlierDetection.java index 73057cb06f08c..f1e9aafed3974 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/OutlierDetection.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/OutlierDetection.java @@ -37,6 +37,7 @@ public class OutlierDetection implements Evaluation { private static final ParseField METRICS = new ParseField("metrics"); + @SuppressWarnings("unchecked") public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( NAME.getPreferredName(), a -> new OutlierDetection((String) a[0], (String) a[1], (List) a[2])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Precision.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Precision.java index cd95f4ccc0558..e955ed2fc94ce 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Precision.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Precision.java @@ -25,6 +25,7 @@ public class Precision extends AbstractConfusionMatrixMetric { public static final ParseField NAME = new ParseField("precision"); + @SuppressWarnings("unchecked") private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(NAME.getPreferredName(), a -> new Precision((List) a[0])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Recall.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Recall.java index 9b115b8fa5885..16c2e5a864968 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Recall.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/evaluation/outlierdetection/Recall.java @@ -25,6 +25,7 @@ public class Recall extends AbstractConfusionMatrixMetric { public static final ParseField NAME = new ParseField("recall"); + @SuppressWarnings("unchecked") private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(NAME.getPreferredName(), a -> new Recall((List) a[0])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java index 065d0d03e8604..52ee567d530a2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/classification/ValidationLoss.java @@ -29,6 +29,7 @@ public static ValidationLoss fromXContent(XContentParser parser, boolean ignoreU return createParser(ignoreUnknownFields).apply(parser, null); } + @SuppressWarnings("unchecked") private static ConstructingObjectParser createParser(boolean ignoreUnknownFields) { ConstructingObjectParser parser = new ConstructingObjectParser<>("classification_validation_loss", ignoreUnknownFields, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/FoldValues.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/FoldValues.java index 1638f18fd493b..09a9a929a1f01 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/FoldValues.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/FoldValues.java @@ -28,6 +28,7 @@ public static FoldValues fromXContent(XContentParser parser, boolean ignoreUnkno return createParser(ignoreUnknownFields).apply(parser, null); } + @SuppressWarnings("unchecked") private static ConstructingObjectParser createParser(boolean ignoreUnknownFields) { ConstructingObjectParser parser = new ConstructingObjectParser<>("fold_values", ignoreUnknownFields, a -> new FoldValues((int) a[0], (List) a[1])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java index 4a1eafcb1b491..ec38b9e6437ef 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/regression/ValidationLoss.java @@ -29,6 +29,7 @@ public static ValidationLoss fromXContent(XContentParser parser, boolean ignoreU return createParser(ignoreUnknownFields).apply(parser, null); } + @SuppressWarnings("unchecked") private static ConstructingObjectParser createParser(boolean ignoreUnknownFields) { ConstructingObjectParser parser = new ConstructingObjectParser<>("regression_validation_loss", ignoreUnknownFields, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java index 3663560b978f3..c99db4e3f67b7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java @@ -31,6 +31,7 @@ public class RuleScope implements ToXContentObject, Writeable { + @SuppressWarnings("unchecked") public static ContextParser parser(boolean ignoreUnknownFields) { return (p, c) -> { Map unparsedScope = p.map(); @@ -42,7 +43,7 @@ public static ContextParser parser(boolean ignoreUnknownFields) Map scope = new HashMap<>(); for (Map.Entry entry : unparsedScope.entrySet()) { try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - builder.map((Map) entry.getValue()); + builder.map((Map) entry.getValue()); try (XContentParser scopeParser = XContentFactory.xContent(builder.contentType()).createParser( NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, Strings.toString(builder))) { scope.put(entry.getKey(), filterRefParser.parse(scopeParser, null)); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influence.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influence.java index ab6ca54f3a160..6b9aeed3d84b7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influence.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Influence.java @@ -33,6 +33,7 @@ public class Influence implements ToXContentObject, Writeable { public static final ConstructingObjectParser STRICT_PARSER = createParser(false); public static final ConstructingObjectParser LENIENT_PARSER = createParser(true); + @SuppressWarnings({ "unchecked"}) private static ConstructingObjectParser createParser(boolean ignoreUnknownFields) { ConstructingObjectParser parser = new ConstructingObjectParser<>(INFLUENCER.getPreferredName(), ignoreUnknownFields, a -> new Influence((String) a[0], (List) a[1])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobStatus.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobStatus.java index 9b5099e90c810..a23fb55587153 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobStatus.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/job/RollupJobStatus.java @@ -45,6 +45,7 @@ public class RollupJobStatus implements Task.Status, PersistentTaskState { private static final ParseField CURRENT_POSITION = new ParseField("current_position"); private static final ParseField UPGRADED_DOC_ID = new ParseField("upgraded_doc_id"); // This can be removed in 9.0 + @SuppressWarnings("unchecked") public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>(NAME, args -> new RollupJobStatus((IndexerState) args[0], (HashMap) args[1])); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/SecurityContext.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/SecurityContext.java index 411be6c79f8c7..5d6c0131cf068 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/SecurityContext.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/SecurityContext.java @@ -166,6 +166,7 @@ public void executeAfterRewritingAuthentication(Consumer consumer } } + @SuppressWarnings("unchecked") private Map rewriteMetadataForApiKeyRoleDescriptors(Version streamVersion, Authentication authentication) { Map metadata = authentication.getMetadata(); if (authentication.getAuthenticationType() == AuthenticationType.API_KEY) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertParsingUtils.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertParsingUtils.java index bba67d6809abe..da1ffaf4d76fd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertParsingUtils.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/CertParsingUtils.java @@ -85,7 +85,7 @@ public static Certificate[] readCertificates(List certPaths) throws Certif CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); for (Path path : certPaths) { try (InputStream input = Files.newInputStream(path)) { - certificates.addAll((Collection) certFactory.generateCertificates(input)); + certificates.addAll(certFactory.generateCertificates(input)); if (certificates.isEmpty()) { throw new CertificateException("failed to parse any certificates from [" + path.toAbsolutePath() + "]"); } @@ -94,6 +94,7 @@ public static Certificate[] readCertificates(List certPaths) throws Certif return certificates.toArray(new Certificate[0]); } + @SuppressWarnings("unchecked") public static X509Certificate[] readX509Certificates(List certPaths) throws CertificateException, IOException { Collection certificates = new ArrayList<>(); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); @@ -107,7 +108,7 @@ public static X509Certificate[] readX509Certificates(List certPaths) throw public static List readCertificates(InputStream input) throws CertificateException, IOException { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); - Collection certificates = (Collection) certFactory.generateCertificates(input); + Collection certificates = certFactory.generateCertificates(input); return new ArrayList<>(certificates); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java index 7337e1e417763..7d537b2fe2fda 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java @@ -51,7 +51,7 @@ public class ActionWrapper implements ToXContentObject { @Nullable private final ExecutableCondition condition; @Nullable - private final ExecutableTransform transform; + private final ExecutableTransform transform; private final ActionThrottler throttler; private final ExecutableAction action; @Nullable @@ -60,10 +60,10 @@ public class ActionWrapper implements ToXContentObject { public ActionWrapper(String id, ActionThrottler throttler, @Nullable ExecutableCondition condition, - @Nullable ExecutableTransform transform, + @Nullable ExecutableTransform transform, ExecutableAction action, @Nullable String path, - @Nullable Integer maxIterations) { + @Nullable Integer maxIterations) { this.id = id; this.condition = condition; this.throttler = throttler; @@ -81,7 +81,7 @@ public ExecutableCondition condition() { return condition; } - public ExecutableTransform transform() { + public ExecutableTransform transform() { return transform; } @@ -107,6 +107,7 @@ public ExecutableAction action() { * @param ctx The current watch's context * @return Never {@code null} */ + @SuppressWarnings("unchecked") public ActionWrapperResult execute(WatchExecutionContext ctx) { ActionWrapperResult result = ctx.actionsResults().get(id); if (result != null) { @@ -173,7 +174,7 @@ public ActionWrapperResult execute(WatchExecutionContext ctx) { Object object = ObjectPath.eval(path, toMap(ctx)); int runs = 0; if (object instanceof Collection) { - Collection collection = Collection.class.cast(object); + Collection collection = Collection.class.cast(object); if (collection.isEmpty()) { throw new ElasticsearchException("foreach object [{}] was an empty list, could not run any action", path); } else { @@ -294,7 +295,7 @@ static ActionWrapper parse(String watchId, String actionId, XContentParser parse assert parser.currentToken() == XContentParser.Token.START_OBJECT; ExecutableCondition condition = null; - ExecutableTransform transform = null; + ExecutableTransform transform = null; TimeValue throttlePeriod = null; String path = null; ExecutableAction action = null; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ExecutableAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ExecutableAction.java index 457f10249e599..35b2fdb39b37b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ExecutableAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ExecutableAction.java @@ -48,7 +48,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ExecutableAction that = (ExecutableAction) o; + ExecutableAction that = (ExecutableAction) o; return action.equals(that.action); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/client/WatchSourceBuilder.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/client/WatchSourceBuilder.java index 12eb6a12ee2ad..3f9cabcb46344 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/client/WatchSourceBuilder.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/client/WatchSourceBuilder.java @@ -43,7 +43,7 @@ public class WatchSourceBuilder implements ToXContentObject { private TimeValue defaultThrottlePeriod = null; private Map metadata; - public WatchSourceBuilder trigger(Trigger.Builder trigger) { + public WatchSourceBuilder trigger(Trigger.Builder trigger) { return trigger(trigger.build()); } @@ -52,7 +52,7 @@ public WatchSourceBuilder trigger(Trigger trigger) { return this; } - public WatchSourceBuilder input(Input.Builder input) { + public WatchSourceBuilder input(Input.Builder input) { return input(input.build()); } @@ -71,7 +71,7 @@ public WatchSourceBuilder transform(Transform transform) { return this; } - public WatchSourceBuilder transform(Transform.Builder transform) { + public WatchSourceBuilder transform(Transform.Builder transform) { return transform(transform.build()); } @@ -80,23 +80,25 @@ public WatchSourceBuilder defaultThrottlePeriod(TimeValue throttlePeriod) { return this; } - public WatchSourceBuilder addAction(String id, Action.Builder action) { + public WatchSourceBuilder addAction(String id, Action.Builder action) { return addAction(id, null, null, action.build()); } - public WatchSourceBuilder addAction(String id, TimeValue throttlePeriod, Action.Builder action) { + public WatchSourceBuilder addAction(String id, TimeValue throttlePeriod, Action.Builder action) { return addAction(id, throttlePeriod, null, action.build()); } - public WatchSourceBuilder addAction(String id, Transform.Builder transform, Action.Builder action) { + public WatchSourceBuilder addAction(String id, Transform.Builder transform, + Action.Builder action) { return addAction(id, null, transform.build(), action.build()); } - public WatchSourceBuilder addAction(String id, Condition condition, Action.Builder action) { + public WatchSourceBuilder addAction(String id, Condition condition, Action.Builder action) { return addAction(id, null, condition, null, action.build()); } - public WatchSourceBuilder addAction(String id, TimeValue throttlePeriod, Transform.Builder transform, Action.Builder action) { + public WatchSourceBuilder addAction(String id, TimeValue throttlePeriod, Transform.Builder transform, + Action.Builder action) { return addAction(id, throttlePeriod, transform.build(), action.build()); } @@ -105,8 +107,8 @@ public WatchSourceBuilder addAction(String id, TimeValue throttlePeriod, Transfo return this; } - public WatchSourceBuilder addAction(String id, TimeValue throttlePeriod, Condition condition, Transform.Builder transform, - Action.Builder action) { + public WatchSourceBuilder addAction(String id, TimeValue throttlePeriod, Condition condition, + Transform.Builder transform, Action.Builder action) { return addAction(id, throttlePeriod, condition, transform.build(), action.build()); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/WatchRecord.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/WatchRecord.java index d8836d9c338bf..49009f2f9326c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/WatchRecord.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/WatchRecord.java @@ -19,6 +19,7 @@ import org.elasticsearch.xpack.core.watcher.execution.WatchExecutionResult; import org.elasticsearch.xpack.core.watcher.execution.Wid; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; +import org.elasticsearch.xpack.core.watcher.input.Input; import org.elasticsearch.xpack.core.watcher.support.xcontent.WatcherParams; import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent; import org.elasticsearch.xpack.core.watcher.watch.Watch; @@ -54,13 +55,14 @@ public abstract class WatchRecord implements ToXContentObject { // only emitted to xcontent in "debug" mode protected final Map vars; - @Nullable protected final ExecutableInput input; + @Nullable protected final ExecutableInput input; @Nullable protected final ExecutableCondition condition; @Nullable protected final Map metadata; @Nullable protected final WatchExecutionResult executionResult; - private WatchRecord(Wid id, TriggerEvent triggerEvent, ExecutionState state, Map vars, ExecutableInput input, - ExecutableCondition condition, Map metadata, Watch watch, WatchExecutionResult executionResult, + private WatchRecord(Wid id, TriggerEvent triggerEvent, ExecutionState state, Map vars, + ExecutableInput input, ExecutableCondition condition, + Map metadata, Watch watch, WatchExecutionResult executionResult, String nodeId, String user) { this.id = id; this.triggerEvent = triggerEvent; @@ -130,7 +132,7 @@ public String watchId() { return id.watchId(); } - public ExecutableInput input() { return input; } + public ExecutableInput input() { return input; } public ExecutionState state() { return state; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherUtils.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherUtils.java index a27add6ab1d13..066e704bc0cf9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherUtils.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/WatcherUtils.java @@ -39,6 +39,7 @@ public static Map flattenModel(Map map) { return result; } + @SuppressWarnings("unchecked") private static void flattenModel(String key, Object value, Map result) { if (value == null) { result.put(key, null); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java index 55362390216a3..33b6839379cd5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; @@ -76,8 +77,8 @@ public boolean isMap() { /** * @return The source as a map */ - public Map getAsMap() { - return (Map) data(); + public Map getAsMap() { + return (Map) data(); } /** @@ -90,8 +91,7 @@ public boolean isList() { /** * @return The source as a list */ - public List getAsList() { - return (List) data(); + public List getAsList() { return ((List) data()); } /** diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/TransformRegistry.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/TransformRegistry.java index 0365b31058378..5a62bc6c52c81 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/TransformRegistry.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/TransformRegistry.java @@ -17,22 +17,26 @@ public class TransformRegistry { - private final Map factories; + private final Map>> factories; - public TransformRegistry(Map factories) { - Map map = new HashMap<>(factories); + public TransformRegistry(Map>> factories) { + Map>> map + = new HashMap<>(factories); map.put(ChainTransform.TYPE, new ChainTransformFactory(this)); this.factories = Collections.unmodifiableMap(map); } - public TransformFactory factory(String type) { + public TransformFactory> factory(String type) { return factories.get(type); } - public ExecutableTransform parse(String watchId, XContentParser parser) throws IOException { + public ExecutableTransform parse(String watchId, XContentParser parser) + throws IOException { String type = null; XContentParser.Token token; - ExecutableTransform transform = null; + ExecutableTransform transform = null; while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { type = parser.currentName(); @@ -43,8 +47,10 @@ public ExecutableTransform parse(String watchId, XContentParser parser) throws I return transform; } - private ExecutableTransform parse(String watchId, String type, XContentParser parser) throws IOException { - TransformFactory factory = factories.get(type); + private ExecutableTransform parse(String watchId, String type, XContentParser parser) + throws IOException { + TransformFactory> factory = factories.get(type); if (factory == null) { throw new ElasticsearchParseException("could not parse transform for watch [{}], unknown transform type [{}]", watchId, type); } @@ -52,7 +58,8 @@ private ExecutableTransform parse(String watchId, String type, XContentParser pa } public Transform parseTransform(String watchId, String type, XContentParser parser) throws IOException { - TransformFactory factory = factories.get(type); + TransformFactory> factory = factories.get(type); if (factory == null) { throw new ElasticsearchParseException("could not parse transform for watch [{}], unknown transform type [{}]", watchId, type); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java index e150f58bc5539..d9b6ca5ffb6eb 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java @@ -149,8 +149,8 @@ public Builder add(Transform... transforms) { return this; } - public Builder add(Transform.Builder... transforms) { - for (Transform.Builder transform: transforms) { + public Builder add(Transform.Builder... transforms) { + for (Transform.Builder transform: transforms) { this.transforms.add(transform.build()); } return this; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransformFactory.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransformFactory.java index 97047abede4fc..80a0021c6ccdf 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransformFactory.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransformFactory.java @@ -35,6 +35,7 @@ public ChainTransform parseTransform(String watchId, XContentParser parser) thro } @Override + @SuppressWarnings({"rawtypes", "unchecked"}) public ExecutableChainTransform createExecutable(ChainTransform chainTransform) { ArrayList executables = new ArrayList<>(); for (Transform transform : chainTransform.getTransforms()) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java index 5887a2bdd6d38..88551742e941d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java @@ -24,22 +24,27 @@ public class ExecutableChainTransform extends ExecutableTransform { + @SuppressWarnings("rawtypes") private final List transforms; + @SuppressWarnings("rawtypes") public ExecutableChainTransform(ChainTransform transform, Logger logger, ExecutableTransform... transforms) { this(transform, logger, Arrays.asList(transforms)); } + @SuppressWarnings("rawtypes") public ExecutableChainTransform(ChainTransform transform, Logger logger, List transforms) { super(transform, logger); this.transforms = Collections.unmodifiableList(transforms); } + @SuppressWarnings("rawtypes") public List executableTransforms() { return transforms; } @Override + @SuppressWarnings("rawtypes") public ChainTransform.Result execute(WatchExecutionContext ctx, Payload payload) { List results = new ArrayList<>(); try { @@ -50,7 +55,7 @@ public ChainTransform.Result execute(WatchExecutionContext ctx, Payload payload) } } - + @SuppressWarnings("rawtypes") ChainTransform.Result doExecute(WatchExecutionContext ctx, Payload payload, List results) throws IOException { for (ExecutableTransform transform : transforms) { Transform.Result result = transform.execute(ctx, payload); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/Watch.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/Watch.java index 29366574134fb..5401653dd2ea3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/Watch.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/Watch.java @@ -14,7 +14,9 @@ import org.elasticsearch.xpack.core.watcher.actions.ActionWrapper; import org.elasticsearch.xpack.core.watcher.condition.ExecutableCondition; import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; +import org.elasticsearch.xpack.core.watcher.input.Input; import org.elasticsearch.xpack.core.watcher.transform.ExecutableTransform; +import org.elasticsearch.xpack.core.watcher.transform.Transform; import org.elasticsearch.xpack.core.watcher.trigger.Trigger; import java.io.IOException; @@ -29,9 +31,9 @@ public class Watch implements ToXContentObject { private final String id; private final Trigger trigger; - private final ExecutableInput input; + private final ExecutableInput input; private final ExecutableCondition condition; - @Nullable private final ExecutableTransform transform; + @Nullable private final ExecutableTransform transform; private final List actions; @Nullable private final TimeValue throttlePeriod; @Nullable private final Map metadata; @@ -40,7 +42,8 @@ public class Watch implements ToXContentObject { private final long sourceSeqNo; private final long sourcePrimaryTerm; - public Watch(String id, Trigger trigger, ExecutableInput input, ExecutableCondition condition, @Nullable ExecutableTransform transform, + public Watch(String id, Trigger trigger, ExecutableInputinput, ExecutableCondition condition, + @Nullable ExecutableTransform transform, @Nullable TimeValue throttlePeriod, List actions, @Nullable Map metadata, WatchStatus status, long sourceSeqNo, long sourcePrimaryTerm) { this.id = id; @@ -64,13 +67,13 @@ public Trigger trigger() { return trigger; } - public ExecutableInput input() { return input;} + public ExecutableInput input() { return input;} public ExecutableCondition condition() { return condition; } - public ExecutableTransform transform() { + public ExecutableTransform transform() { return transform; } From 932190cd4611dd46ec11adee36e2ba63b77de31e Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 30 Dec 2020 19:18:25 -0800 Subject: [PATCH 02/15] removed more warnings --- .../java/org/elasticsearch/client/common/XContentSource.java | 5 ++--- .../ml/dataframe/stats/classification/ValidationLoss.java | 2 +- .../java/org/elasticsearch/common/xcontent/ObjectPath.java | 5 ++--- x-pack/plugin/core/build.gradle | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java index 689f82f18b9a6..7cf37fe26a20b 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java @@ -77,9 +77,8 @@ public List getAsList() { * @param path a dot notation path to the requested value * @return The extracted value or {@code null} if no value is associated with the given path */ - @SuppressWarnings("unchecked") - public T getValue(String path) { - return (T) ObjectPath.eval(path, data); + public Object getValue(String path) { + return ObjectPath.eval(path, data); } } diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java index 19dce73406805..a552f5d85e124 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/classification/ValidationLoss.java @@ -33,7 +33,7 @@ public class ValidationLoss implements ToXContentObject { public static final ParseField LOSS_TYPE = new ParseField("loss_type"); public static final ParseField FOLD_VALUES = new ParseField("fold_values"); - @SuppressWarnings({"unchecked"}) + @SuppressWarnings("unchecked") public static ConstructingObjectParser PARSER = new ConstructingObjectParser<>("classification_validation_loss", true, a -> new ValidationLoss((String) a[0], (List) a[1])); diff --git a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java index 8a70f9cb70474..64e08993efc6f 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java +++ b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java @@ -37,9 +37,8 @@ private ObjectPath() { * Return the value within a given object at the specified path, or * {@code null} if the path does not exist */ - @SuppressWarnings("unchecked") - public static T eval(String path, Object object) { - return (T) evalContext(path, object); + public static Object eval(String path, Object object) { + return evalContext(path, object); } private static Object evalContext(String path, Object ctx) { diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index 8314056a46629..2fd2bd5153295 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -118,7 +118,6 @@ test { } // TODO: don't publish test artifacts just to run messy tests, fix the tests! -// https://github.com/elastic/x-plugins/issues/724 configurations { testArtifacts.extendsFrom testRuntime testArtifacts.extendsFrom testImplementation From ed3b9e47882d5d9a44dd8fdde25475ec445b4a5b Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Thu, 31 Dec 2020 12:20:20 -0800 Subject: [PATCH 03/15] suppressed more unchecked warnings --- .../java/org/elasticsearch/client/common/XContentSource.java | 5 +++-- .../java/org/elasticsearch/common/xcontent/ObjectPath.java | 5 +++-- .../core/security/authz/accesscontrol/FieldSubsetReader.java | 2 ++ .../xpack/core/watcher/support/xcontent/XContentSource.java | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java index 7cf37fe26a20b..689f82f18b9a6 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/common/XContentSource.java @@ -77,8 +77,9 @@ public List getAsList() { * @param path a dot notation path to the requested value * @return The extracted value or {@code null} if no value is associated with the given path */ - public Object getValue(String path) { - return ObjectPath.eval(path, data); + @SuppressWarnings("unchecked") + public T getValue(String path) { + return (T) ObjectPath.eval(path, data); } } diff --git a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java index 64e08993efc6f..8a70f9cb70474 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java +++ b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/ObjectPath.java @@ -37,8 +37,9 @@ private ObjectPath() { * Return the value within a given object at the specified path, or * {@code null} if the path does not exist */ - public static Object eval(String path, Object object) { - return evalContext(path, object); + @SuppressWarnings("unchecked") + public static T eval(String path, Object object) { + return (T) evalContext(path, object); } private static Object evalContext(String path, Object ctx) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/FieldSubsetReader.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/FieldSubsetReader.java index 372c6bc017a14..495cd27528a4d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/FieldSubsetReader.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/FieldSubsetReader.java @@ -159,6 +159,7 @@ public Fields getTermVectors(int docID) throws IOException { } /** Filter a map by a {@link CharacterRunAutomaton} that defines the fields to retain. */ + @SuppressWarnings("unchecked") static Map filter(Map map, CharacterRunAutomaton includeAutomaton, int initialState) { Map filtered = new HashMap<>(); for (Map.Entry entry : map.entrySet()) { @@ -196,6 +197,7 @@ static Map filter(Map map, CharacterRunAutomaton incl } /** Filter a list by a {@link CharacterRunAutomaton} that defines the fields to retain. */ + @SuppressWarnings("unchecked") private static List filter(Iterable iterable, CharacterRunAutomaton includeAutomaton, int initialState) { List filtered = new ArrayList<>(); for (Object value : iterable) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java index 33b6839379cd5..e3f7a2dd7d618 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java @@ -100,6 +100,7 @@ public boolean isList() { * @param path a dot notation path to the requested value * @return The extracted value or {@code null} if no value is associated with the given path */ + @SuppressWarnings("unchecked") public T getValue(String path) { return (T) ObjectPath.eval(path, data()); } From e369db65580b321d0f01173bf5d39fd6e7aa1cdb Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Thu, 31 Dec 2020 14:44:13 -0800 Subject: [PATCH 04/15] Added wildcard for transform.builder --- .../xpack/core/watcher/transform/chain/ChainTransform.java | 4 ++-- .../xpack/watcher/transform/TransformBuilders.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java index d9b6ca5ffb6eb..ac84dcd228c54 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ChainTransform.java @@ -149,8 +149,8 @@ public Builder add(Transform... transforms) { return this; } - public Builder add(Transform.Builder... transforms) { - for (Transform.Builder transform: transforms) { + public Builder add(Transform.Builder... transforms) { + for (Transform.Builder transform: transforms) { this.transforms.add(transform.build()); } return this; diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java index 29df7c787d740..3dc824e619a65 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transform/TransformBuilders.java @@ -32,7 +32,7 @@ public static ScriptTransform.Builder scriptTransform(Script script) { return ScriptTransform.builder(script); } - public static ChainTransform.Builder chainTransform(Transform.Builder... transforms) { + public static ChainTransform.Builder chainTransform(Transform.Builder... transforms) { return ChainTransform.builder().add(transforms); } From c420a279944ff003c47d90867a1d76d594f4936d Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Tue, 26 Jan 2021 18:41:20 -0800 Subject: [PATCH 05/15] feedback resolved --- .../core/watcher/support/xcontent/XContentSource.java | 6 +++--- .../watcher/transform/chain/ExecutableChainTransform.java | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java index e3f7a2dd7d618..238bcd57191a2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java @@ -77,8 +77,8 @@ public boolean isMap() { /** * @return The source as a map */ - public Map getAsMap() { - return (Map) data(); + public Map getAsMap() { + return (Map) data(); } /** @@ -91,7 +91,7 @@ public boolean isList() { /** * @return The source as a list */ - public List getAsList() { return ((List) data()); + public List getAsList() { return ((List) data()); } /** diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java index 88551742e941d..a4a9b75a36f2c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transform/chain/ExecutableChainTransform.java @@ -22,29 +22,25 @@ import static org.elasticsearch.common.logging.LoggerMessageFormat.format; import static org.elasticsearch.xpack.core.watcher.transform.chain.ChainTransform.TYPE; +@SuppressWarnings("rawtypes") public class ExecutableChainTransform extends ExecutableTransform { - @SuppressWarnings("rawtypes") private final List transforms; - @SuppressWarnings("rawtypes") public ExecutableChainTransform(ChainTransform transform, Logger logger, ExecutableTransform... transforms) { this(transform, logger, Arrays.asList(transforms)); } - @SuppressWarnings("rawtypes") public ExecutableChainTransform(ChainTransform transform, Logger logger, List transforms) { super(transform, logger); this.transforms = Collections.unmodifiableList(transforms); } - @SuppressWarnings("rawtypes") public List executableTransforms() { return transforms; } @Override - @SuppressWarnings("rawtypes") public ChainTransform.Result execute(WatchExecutionContext ctx, Payload payload) { List results = new ArrayList<>(); try { @@ -55,7 +51,6 @@ public ChainTransform.Result execute(WatchExecutionContext ctx, Payload payload) } } - @SuppressWarnings("rawtypes") ChainTransform.Result doExecute(WatchExecutionContext ctx, Payload payload, List results) throws IOException { for (ExecutableTransform transform : transforms) { Transform.Result result = transform.execute(ctx, payload); From e32d7f16c271ad0d66cd9e251be88553db7111a6 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Tue, 26 Jan 2021 18:58:20 -0800 Subject: [PATCH 06/15] revereted XCOntentSource to master partially as per feedback --- .../xpack/core/watcher/support/xcontent/XContentSource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java index 238bcd57191a2..a8c890a849182 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; @@ -91,7 +90,8 @@ public boolean isList() { /** * @return The source as a list */ - public List getAsList() { return ((List) data()); + public List getAsList() { + return (List) data(); } /** From 7a8f0d0f47a45375cf4176a1d5539a6bfe5bbfa0 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Thu, 28 Jan 2021 12:31:09 -0800 Subject: [PATCH 07/15] fixed few more warnings --- .../xpack/core/watcher/support/xcontent/XContentSource.java | 2 ++ .../src/test/java/org/elasticsearch/test/TestMatchers.java | 1 + .../xpack/core/action/TransportXPackInfoActionTests.java | 2 +- .../xpack/core/ilm/CloseFollowerIndexStepTests.java | 2 +- .../xpack/core/ilm/OpenFollowerIndexStepTests.java | 2 +- .../xpack/core/ilm/PauseFollowerIndexStepTests.java | 2 +- .../xpack/core/ilm/UnfollowFollowIndexStepTests.java | 4 ++-- 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java index a8c890a849182..9945ef2bd1a04 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/support/xcontent/XContentSource.java @@ -76,6 +76,7 @@ public boolean isMap() { /** * @return The source as a map */ + @SuppressWarnings("unchecked") public Map getAsMap() { return (Map) data(); } @@ -90,6 +91,7 @@ public boolean isList() { /** * @return The source as a list */ + @SuppressWarnings("unchecked") public List getAsList() { return (List) data(); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/test/TestMatchers.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/test/TestMatchers.java index c1a290f509a58..5c513325f1810 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/test/TestMatchers.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/test/TestMatchers.java @@ -66,6 +66,7 @@ public void describeMismatch(Object item, Description description) { }; } + @SuppressWarnings("unchecked") public static Matcher> predicateMatches(T value) { return new CustomMatcher>("Matches " + value) { @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/action/TransportXPackInfoActionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/action/TransportXPackInfoActionTests.java index a5f27f73ab3d7..3eb05deed76a8 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/action/TransportXPackInfoActionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/action/TransportXPackInfoActionTests.java @@ -42,6 +42,7 @@ public class TransportXPackInfoActionTests extends ESTestCase { + @SuppressWarnings("unchecked") public void testDoExecute() throws Exception { LicenseService licenseService = mock(LicenseService.class); @@ -53,7 +54,6 @@ public void testDoExecute() throws Exception { FeatureSet featureSet = new FeatureSet(randomAlphaOfLength(5), randomBoolean(), randomBoolean()); featureSets.put(infoAction, featureSet); stub(client.executeLocally(eq(infoAction), any(ActionRequest.class), any(ActionListener.class))).toAnswer(answer -> { - @SuppressWarnings("unchecked") var listener = (ActionListener)answer.getArguments()[2]; listener.onResponse(new XPackInfoFeatureResponse(featureSet)); return null; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CloseFollowerIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CloseFollowerIndexStepTests.java index 0de516a25d40e..42e572e117835 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CloseFollowerIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CloseFollowerIndexStepTests.java @@ -70,7 +70,7 @@ public void testCloseFollowingIndexFailed() { Mockito.doAnswer(invocation -> { CloseIndexRequest closeIndexRequest = (CloseIndexRequest) invocation.getArguments()[0]; assertThat(closeIndexRequest.indices()[0], equalTo("follower-index")); - ActionListener listener = (ActionListener) invocation.getArguments()[1]; + ActionListenerlistener = (ActionListener) invocation.getArguments()[1]; listener.onFailure(error); return null; }).when(indicesClient).close(Mockito.any(), Mockito.any()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java index 996a592bc9c3c..84dbe5dbda545 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java @@ -125,7 +125,7 @@ public void testOpenFollowingIndexFailed() { Mockito.doAnswer(invocation -> { OpenIndexRequest closeIndexRequest = (OpenIndexRequest) invocation.getArguments()[0]; assertThat(closeIndexRequest.indices()[0], equalTo("follower-index")); - ActionListener listener = (ActionListener) invocation.getArguments()[1]; + ActionListener listener = (ActionListener) invocation.getArguments()[1]; listener.onFailure(error); return null; }).when(indicesClient).open(Mockito.any(), Mockito.any()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/PauseFollowerIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/PauseFollowerIndexStepTests.java index 77f95c62e2532..f43fd358e7b14 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/PauseFollowerIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/PauseFollowerIndexStepTests.java @@ -76,7 +76,7 @@ public void testPauseFollowingIndexFailed() { Mockito.doAnswer(invocation -> { PauseFollowAction.Request request = (PauseFollowAction.Request) invocation.getArguments()[1]; assertThat(request.getFollowIndex(), equalTo("follower-index")); - ActionListener listener = (ActionListener) invocation.getArguments()[2]; + ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onFailure(error); return null; }).when(client).execute(Mockito.same(PauseFollowAction.INSTANCE), Mockito.any(), Mockito.any()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowIndexStepTests.java index 220044aa3bfa8..9aed49742636a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowIndexStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/UnfollowFollowIndexStepTests.java @@ -78,7 +78,7 @@ public void testUnFollowUnfollowFailed() { Mockito.doAnswer(invocation -> { UnfollowAction.Request request = (UnfollowAction.Request) invocation.getArguments()[1]; assertThat(request.getFollowerIndex(), equalTo("follower-index")); - ActionListener listener = (ActionListener) invocation.getArguments()[2]; + ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onFailure(error); return null; }).when(client).execute(Mockito.same(UnfollowAction.INSTANCE), Mockito.any(), Mockito.any()); @@ -115,7 +115,7 @@ public void testFailureToReleaseRetentionLeases() { Mockito.doAnswer(invocation -> { UnfollowAction.Request request = (UnfollowAction.Request) invocation.getArguments()[1]; assertThat(request.getFollowerIndex(), equalTo("follower-index")); - ActionListener listener = (ActionListener) invocation.getArguments()[2]; + ActionListener listener = (ActionListener) invocation.getArguments()[2]; listener.onFailure(error); return null; }).when(client).execute(Mockito.same(UnfollowAction.INSTANCE), Mockito.any(), Mockito.any()); From 57016bbe1caf3ec22e66a677c9d62104200f6b9d Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 10 Mar 2021 12:33:50 -0800 Subject: [PATCH 08/15] Fix warnings in Test code --- .../xpack/core/LocalStateCompositeXPackPlugin.java | 1 + .../core/ml/dataframe/analyses/ClassificationTests.java | 1 + .../core/ml/dataframe/analyses/RegressionTests.java | 1 + .../ml/inference/InferenceToXContentCompressorTests.java | 1 + .../core/ml/inference/NamedXContentObjectsTests.java | 1 + .../xpack/core/ml/inference/TrainedModelConfigTests.java | 3 +++ .../core/ml/inference/TrainedModelDefinitionTests.java | 1 + .../inference/trainedmodel/ensemble/EnsembleTests.java | 1 + .../core/ml/integration/MlRestTestStateCleaner.java | 1 + .../ml/job/persistence/ElasticsearchMappingsTests.java | 3 ++- .../xpack/core/ml/job/results/AnomalyRecordTests.java | 1 + .../xpack/core/ml/utils/MlIndexAndAliasTests.java | 2 +- .../core/security/action/role/PutRoleRequestTests.java | 1 + .../action/token/InvalidateTokenResponseTests.java | 4 ++-- .../privilege/ApplicationPrivilegeDescriptorTests.java | 2 ++ .../authz/privilege/ApplicationPrivilegeTests.java | 2 ++ .../xpack/core/watcher/common/stats/CountersTests.java | 1 + .../watcher/input/transform/TransformInputTests.java | 9 +++++---- 18 files changed, 28 insertions(+), 8 deletions(-) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java index 950a371e07c07..689e42c35adeb 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java @@ -527,6 +527,7 @@ public Map getRecoveryStateFactories() { return factories; } + @SuppressWarnings("unchecked") private List filterPlugins(Class type) { return plugins.stream().filter(x -> type.isAssignableFrom(x.getClass())).map(p -> ((T)p)) .collect(Collectors.toList()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java index ee20eb687780b..d9bfb29468b00 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java @@ -85,6 +85,7 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() { return new NamedWriteableRegistry(entries); } + @SuppressWarnings({"unchecked"}) public static Classification createRandom() { String dependentVariableName = randomAlphaOfLength(10); BoostedTreeParams boostedTreeParams = BoostedTreeParamsTests.createRandom(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java index 248f7f8236292..413a1e7c959c3 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java @@ -81,6 +81,7 @@ public static Regression createRandom() { return createRandom(BoostedTreeParamsTests.createRandom()); } + @SuppressWarnings({"unchecked"}) private static Regression createRandom(BoostedTreeParams boostedTreeParams) { String dependentVariableName = randomAlphaOfLength(10); String predictionFieldName = randomBoolean() ? null : randomAlphaOfLength(10); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java index d8ca7130a3be3..b719af3784c18 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java @@ -19,6 +19,7 @@ import static org.hamcrest.Matchers.equalTo; +@SuppressWarnings({"unchecked"}) public class InferenceToXContentCompressorTests extends ESTestCase { public void testInflateAndDeflate() throws IOException { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java index 2db86e64e3502..66f502dadbd80 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java @@ -146,6 +146,7 @@ public void chooseStrictOrLenient() { lenient = randomBoolean(); } + @SuppressWarnings({"unchecked"}) @Override public NamedObjectContainer createTestInstance() { int max = randomIntBetween(1, 10); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java index 0479263162a00..dad8b0c94b349 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java @@ -52,6 +52,7 @@ public class TrainedModelConfigTests extends AbstractBWCSerializationTestCase tags = Arrays.asList(generateRandomStringArray(randomIntBetween(0, 5), 15, false)); return TrainedModelConfig.builder() @@ -128,6 +129,7 @@ protected boolean assertToXContentEquivalence() { return false; } + @SuppressWarnings({"unchecked"}) public void testToXContentWithParams() throws IOException { TrainedModelConfig.LazyModelDefinition lazyModelDefinition = TrainedModelConfig.LazyModelDefinition .fromParsedDefinition(TrainedModelDefinitionTests.createRandomBuilder().build()); @@ -168,6 +170,7 @@ public void testToXContentWithParams() throws IOException { assertThat(reference.utf8ToString(), not(containsString("compressed_definition"))); } + @SuppressWarnings({"unchecked"}) public void testParseWithBothDefinitionAndCompressedSupplied() throws IOException { TrainedModelConfig.LazyModelDefinition lazyModelDefinition = TrainedModelConfig.LazyModelDefinition .fromParsedDefinition(TrainedModelDefinitionTests.createRandomBuilder().build()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java index 35f5dc8e6ef05..953705b680f68 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java @@ -58,6 +58,7 @@ protected boolean assertToXContentEquivalence() { return false; } + @SuppressWarnings({"unchecked"}) public static TrainedModelDefinition.Builder createRandomBuilder(TargetType targetType) { int numberOfProcessors = randomIntBetween(1, 10); return new TrainedModelDefinition.Builder() diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java index 51179db17f427..b40bd03a2de8d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java @@ -64,6 +64,7 @@ public static Ensemble createRandom(TargetType targetType) { return createRandom(targetType, featureNames); } + @SuppressWarnings({"unchecked"}) public static Ensemble createRandom(TargetType targetType, List featureNames) { int numberOfModels = randomIntBetween(1, 10); List treeFeatureNames = featureNames.isEmpty() ? diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java index a2eca1e8b0fbd..df332ba9dacd6 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/integration/MlRestTestStateCleaner.java @@ -93,6 +93,7 @@ private void deleteAllJobs() throws IOException { } } + @SuppressWarnings({"unchecked"}) private void deleteAllDataFrameAnalytics() throws IOException { stopAllDataFrameAnalytics(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java index d079832d90cc9..79818030745c2 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappingsTests.java @@ -194,6 +194,7 @@ public void testMappingRequiresUpdateNewerMappingVersionMinor() throws IOExcepti ElasticsearchMappings.mappingRequiresUpdate(cs, indices, VersionUtils.getPreviousMinorVersion())); } + @SuppressWarnings({"unchecked"}) public void testAddDocMappingIfMissing() { ThreadPool threadPool = mock(ThreadPool.class); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); @@ -201,7 +202,7 @@ public void testAddDocMappingIfMissing() { when(client.threadPool()).thenReturn(threadPool); doAnswer( invocationOnMock -> { - ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; + ActionListener listener = (ActionListener) invocationOnMock.getArguments()[2]; listener.onResponse(AcknowledgedResponse.TRUE); return null; }) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecordTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecordTests.java index c300d8d908f0e..88164ca927388 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecordTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/job/results/AnomalyRecordTests.java @@ -132,6 +132,7 @@ public void testToXContentIncludesInputFields() throws IOException { assertEquals(influence2.getInfluencerFieldValues(), serialisedInfFieldValues2); } + @SuppressWarnings({"unchecked"}) public void testToXContentOrdersDuplicateInputFields() throws IOException { AnomalyRecord record = createTestInstance(); record.setByFieldName("car-make"); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlIndexAndAliasTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlIndexAndAliasTests.java index d1b266a369e87..106204d5b6771 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlIndexAndAliasTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/utils/MlIndexAndAliasTests.java @@ -80,6 +80,7 @@ public class MlIndexAndAliasTests extends ESTestCase { private ArgumentCaptor createRequestCaptor; private ArgumentCaptor aliasesRequestCaptor; + @SuppressWarnings("unchecked") @Before public void setUpMocks() { threadPool = mock(ThreadPool.class); @@ -95,7 +96,6 @@ public void setUpMocks() { clusterAdminClient = mock(ClusterAdminClient.class); doAnswer(invocationOnMock -> { - @SuppressWarnings("unchecked") ActionListener listener = (ActionListener) invocationOnMock.getArguments()[1]; listener.onResponse(new ClusterHealthResponse()); return null; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java index b057547f2a3e9..551dda6f0b735 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java @@ -130,6 +130,7 @@ private PutRoleRequest buildRequestWithApplicationPrivilege(String appName, Stri return request; } + @SuppressWarnings("unchecked") private PutRoleRequest buildRandomRequest() { final PutRoleRequest request = new PutRoleRequest(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/token/InvalidateTokenResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/token/InvalidateTokenResponseTests.java index 471c3e8fa0d07..9aaea61597250 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/token/InvalidateTokenResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/token/InvalidateTokenResponseTests.java @@ -62,8 +62,8 @@ public void testSerialization() throws IOException { } public void testToXContent() throws IOException { - List invalidatedTokens = Arrays.asList(generateRandomStringArray(20, 15, false)); - List previouslyInvalidatedTokens = Arrays.asList(generateRandomStringArray(20, 15, false)); + List invalidatedTokens = Arrays.asList(generateRandomStringArray(20, 15, false)); + List previouslyInvalidatedTokens = Arrays.asList(generateRandomStringArray(20, 15, false)); TokensInvalidationResult result = new TokensInvalidationResult(invalidatedTokens, previouslyInvalidatedTokens, Arrays.asList(new ElasticsearchException("foo", new IllegalArgumentException("this is an error message")), new ElasticsearchException("bar", new IllegalArgumentException("this is an error message2"))), RestStatus.OK); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java index 9db998bd2d1d2..7b09a02c65c25 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java @@ -31,6 +31,7 @@ public class ApplicationPrivilegeDescriptorTests extends ESTestCase { + @SuppressWarnings("unchecked") public void testEqualsAndHashCode() { final ApplicationPrivilegeDescriptor privilege = randomPrivilege(); final EqualsHashCodeTestUtils.MutateFunction mutate = randomFrom( @@ -119,6 +120,7 @@ public void testParseXContentWithoutUsingDefaultNames() throws IOException { } } + @SuppressWarnings("unchecked") private ApplicationPrivilegeDescriptor randomPrivilege() { final String applicationName; if (randomBoolean()) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java index cd917ed81f16e..b54304bb57d9c 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java @@ -150,6 +150,7 @@ private ApplicationPrivilegeDescriptor descriptor(String application, String nam return new ApplicationPrivilegeDescriptor(application, name, Sets.newHashSet(actions), Collections.emptyMap()); } + @SuppressWarnings("unchecked") public void testEqualsAndHashCode() { final ApplicationPrivilege privilege = randomPrivilege(); final EqualsHashCodeTestUtils.MutateFunction mutate = randomFrom( @@ -194,6 +195,7 @@ private void assertNoException(String reason, ThrowingRunnable body) { } } + @SuppressWarnings("unchecked") private ApplicationPrivilege randomPrivilege() { final String applicationName; if (randomBoolean()) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/watcher/common/stats/CountersTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/watcher/common/stats/CountersTests.java index 7288adc2afc3f..8c8e9255e28bd 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/watcher/common/stats/CountersTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/watcher/common/stats/CountersTests.java @@ -15,6 +15,7 @@ public class CountersTests extends ESTestCase { + @SuppressWarnings("unchecked") public void testCounters() { Counters counters = new Counters(); counters.inc("f", 200); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java index 72f473a611d57..98a2c2e6413a6 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.input.Input; import org.elasticsearch.xpack.core.watcher.transform.ExecutableTransform; +import org.elasticsearch.xpack.core.watcher.transform.Transform; import org.elasticsearch.xpack.core.watcher.transform.TransformFactory; import org.elasticsearch.xpack.core.watcher.transform.TransformRegistry; import org.elasticsearch.xpack.core.watcher.watch.Payload; @@ -60,8 +61,8 @@ public void testExecute() { } public void testParserValid() throws Exception { - Map transformFactories = Collections.singletonMap("script", - new ScriptTransformFactory(scriptService)); + Map>> transformFactories = + Collections.singletonMap("script", new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); TransformInputFactory factory = new TransformInputFactory(registry); @@ -84,7 +85,7 @@ public void testParserValid() throws Exception { public void testParserInvalid() throws Exception { XContentBuilder jsonBuilder = jsonBuilder().value("just a string"); - Map transformFactories = Collections.singletonMap("script", + Map>> transformFactories = Collections.singletonMap("script", new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); TransformInputFactory factory = new TransformInputFactory(registry); @@ -103,7 +104,7 @@ public void testTransformResultToXContent() throws Exception { } public void testTransformInputToXContentIsSameAsParsing() throws Exception { - Map transformFactories = Collections.singletonMap("script", + Map>> transformFactories = Collections.singletonMap("script", new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); TransformInputFactory factory = new TransformInputFactory(registry); From d5b1de35b2038132eb0bae4d07a15f5750f38e09 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 10 Mar 2021 13:01:19 -0800 Subject: [PATCH 09/15] Fix errors by capturing derived objects into base class, specifying input types for builder --- .../test/integration/HistoryIntegrationTests.java | 6 +++--- .../xpack/watcher/WatcherServiceTests.java | 3 ++- .../input/transform/TransformInputTests.java | 13 ++++++++----- .../xpack/watcher/trigger/TriggerServiceTests.java | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java index 94ae169158947..2c7dfd324e83e 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/HistoryIntegrationTests.java @@ -81,7 +81,7 @@ public void testFailedInputResultWithDotsInFieldNameGetsStored() throws Exceptio // The result of the search input will be a failure, because a missing index does not exist when // the query is executed @SuppressWarnings({"rawtypes"}) - Input.Builder input = searchInput(request); + Input.Builder input = searchInput(request); // wrapping this randomly into a chained input to test this as well boolean useChained = randomBoolean(); if (useChained) { @@ -120,8 +120,8 @@ public void testFailedInputResultWithDotsInFieldNameGetsStored() throws Exceptio // See https://github.com/elastic/x-plugins/issues/2913 public void testPayloadInputWithDotsInFieldNameWorks() throws Exception { - @SuppressWarnings({"rawtypes"}) - Input.Builder input = simpleInput("foo.bar", "bar"); + + Input.Builder input = simpleInput("foo.bar", "bar"); // wrapping this randomly into a chained input to test this as well boolean useChained = randomBoolean(); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java index d9717793eb0ec..03514bad83a72 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherServiceTests.java @@ -46,6 +46,7 @@ import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.trigger.Trigger; import org.elasticsearch.xpack.core.watcher.watch.Watch; import org.elasticsearch.xpack.core.watcher.watch.WatchStatus; @@ -234,7 +235,7 @@ public void testPausingWatcherServiceAlsoPausesTriggerService() { when(watch.trigger()).thenReturn(trigger); when(watch.id()).thenReturn(id); when(watch.condition()).thenReturn(InternalAlwaysCondition.INSTANCE); - ExecutableNoneInput noneInput = new ExecutableNoneInput(); + ExecutableInput noneInput = new ExecutableNoneInput(); when(watch.input()).thenReturn(noneInput); triggerService.add(watch); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java index 98a2c2e6413a6..df275dae39bca 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/input/transform/TransformInputTests.java @@ -61,7 +61,8 @@ public void testExecute() { } public void testParserValid() throws Exception { - Map>> transformFactories = + Map>> transformFactories = Collections.singletonMap("script", new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); TransformInputFactory factory = new TransformInputFactory(registry); @@ -85,8 +86,9 @@ public void testParserValid() throws Exception { public void testParserInvalid() throws Exception { XContentBuilder jsonBuilder = jsonBuilder().value("just a string"); - Map>> transformFactories = Collections.singletonMap("script", - new ScriptTransformFactory(scriptService)); + Map>> transformFactories = + Collections.singletonMap("script", new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); TransformInputFactory factory = new TransformInputFactory(registry); XContentParser parser = createParser(jsonBuilder); @@ -104,8 +106,9 @@ public void testTransformResultToXContent() throws Exception { } public void testTransformInputToXContentIsSameAsParsing() throws Exception { - Map>> transformFactories = Collections.singletonMap("script", - new ScriptTransformFactory(scriptService)); + Map>> transformFactories = + Collections.singletonMap("script", new ScriptTransformFactory(scriptService)); TransformRegistry registry = new TransformRegistry(transformFactories); TransformInputFactory factory = new TransformInputFactory(registry); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java index 1e1dd6050b486..2aa6f5669e5cc 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/trigger/TriggerServiceTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.xpack.core.watcher.actions.ExecutableAction; import org.elasticsearch.xpack.core.watcher.common.stats.Counters; import org.elasticsearch.xpack.core.watcher.condition.ExecutableCondition; +import org.elasticsearch.xpack.core.watcher.input.ExecutableInput; import org.elasticsearch.xpack.core.watcher.transform.ExecutableTransform; import org.elasticsearch.xpack.core.watcher.trigger.Trigger; import org.elasticsearch.xpack.core.watcher.watch.Watch; @@ -143,7 +144,7 @@ private Watch createWatch(String id) { } private void setInput(Watch watch) { - ExecutableNoneInput noneInput = new ExecutableNoneInput(); + ExecutableInput noneInput = new ExecutableNoneInput(); when(watch.input()).thenReturn(noneInput); } From a0c470edc0eb7c1c9b18d57c0fbd0aa065eea5aa Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 10 Mar 2021 15:10:16 -0800 Subject: [PATCH 10/15] fix warnings with latestConfig unchecked types --- .../xpack/core/transform/transforms/latest/LatestConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfig.java index 5986c341bf9f6..d9da0f2b31b91 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfig.java @@ -44,6 +44,7 @@ public class LatestConfig implements Writeable, ToXContentObject { private static final ConstructingObjectParser STRICT_PARSER = createParser(false); private static final ConstructingObjectParser LENIENT_PARSER = createParser(true); + @SuppressWarnings("unchecked") private static ConstructingObjectParser createParser(boolean lenient) { ConstructingObjectParser parser = new ConstructingObjectParser<>(NAME, lenient, args -> new LatestConfig((List) args[0], (String) args[1])); From ef10bb5dd4000c846fbfb57538ff9c3447c554dd Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 10 Mar 2021 15:11:55 -0800 Subject: [PATCH 11/15] resolve SourceConfig unchecked --- .../xpack/core/transform/transforms/SourceConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/SourceConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/SourceConfig.java index a907ea7acc04e..ef528e6b13995 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/SourceConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/SourceConfig.java @@ -42,11 +42,11 @@ public class SourceConfig implements Writeable, ToXContentObject { public static final ConstructingObjectParser STRICT_PARSER = createParser(false); public static final ConstructingObjectParser LENIENT_PARSER = createParser(true); + @SuppressWarnings("unchecked") private static ConstructingObjectParser createParser(boolean lenient) { ConstructingObjectParser parser = new ConstructingObjectParser<>("data_frame_config_source", lenient, args -> { - @SuppressWarnings("unchecked") String[] index = ((List)args[0]).toArray(new String[0]); // default handling: if the user does not specify a query, we default to match_all QueryConfig queryConfig = args[1] == null ? QueryConfig.matchAll() : (QueryConfig) args[1]; From 7ec988a72a0eced4900e652b4426e164e4c9da79 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 10 Mar 2021 15:15:01 -0800 Subject: [PATCH 12/15] remove OpenFollwerIndexStepTests as deleted from source --- .../core/ilm/OpenFollowerIndexStepTests.java | 152 ------------------ 1 file changed, 152 deletions(-) delete mode 100644 x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java deleted file mode 100644 index 84dbe5dbda545..0000000000000 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/OpenFollowerIndexStepTests.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.xpack.core.ilm; - -import org.elasticsearch.Version; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.open.OpenIndexRequest; -import org.elasticsearch.action.admin.indices.open.OpenIndexResponse; -import org.elasticsearch.cluster.metadata.IndexMetadata; -import org.mockito.Mockito; - -import java.util.Collections; - -import static org.elasticsearch.xpack.core.ilm.UnfollowAction.CCR_METADATA_KEY; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.Matchers.sameInstance; - -public class OpenFollowerIndexStepTests extends AbstractStepMasterTimeoutTestCase { - - @Override - protected OpenFollowerIndexStep createRandomInstance() { - Step.StepKey stepKey = randomStepKey(); - Step.StepKey nextStepKey = randomStepKey(); - return new OpenFollowerIndexStep(stepKey, nextStepKey, client); - } - - @Override - protected OpenFollowerIndexStep mutateInstance(OpenFollowerIndexStep instance) { - Step.StepKey key = instance.getKey(); - Step.StepKey nextKey = instance.getNextStepKey(); - - if (randomBoolean()) { - key = new Step.StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5)); - } else { - nextKey = new Step.StepKey(key.getPhase(), key.getAction(), key.getName() + randomAlphaOfLength(5)); - } - - return new OpenFollowerIndexStep(key, nextKey, instance.getClient()); - } - - @Override - protected OpenFollowerIndexStep copyInstance(OpenFollowerIndexStep instance) { - return new OpenFollowerIndexStep(instance.getKey(), instance.getNextStepKey(), instance.getClient()); - } - - @Override - protected IndexMetadata getIndexMetadata() { - return IndexMetadata.builder("follower-index") - .settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE, "true")) - .putCustom(CCR_METADATA_KEY, Collections.emptyMap()) - .state(IndexMetadata.State.CLOSE) - .numberOfShards(1) - .numberOfReplicas(0) - .build(); - } - - public void testOpenFollowerIndexIsNoopForAlreadyOpenIndex() { - IndexMetadata indexMetadata = IndexMetadata.builder("follower-index") - .settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE, "true")) - .putCustom(CCR_METADATA_KEY, Collections.emptyMap()) - .state(IndexMetadata.State.OPEN) - .numberOfShards(1) - .numberOfReplicas(0) - .build(); - OpenFollowerIndexStep step = new OpenFollowerIndexStep(randomStepKey(), randomStepKey(), client); - step.performAction(indexMetadata, null, null, new AsyncActionStep.Listener() { - @Override - public void onResponse(boolean complete) { - assertThat(complete, is(true)); - } - - @Override - public void onFailure(Exception e) { - } - }); - - Mockito.verifyZeroInteractions(client); - } - - public void testOpenFollowingIndex() { - IndexMetadata indexMetadata = getIndexMetadata(); - - Mockito.doAnswer(invocation -> { - OpenIndexRequest closeIndexRequest = (OpenIndexRequest) invocation.getArguments()[0]; - assertThat(closeIndexRequest.indices()[0], equalTo("follower-index")); - @SuppressWarnings("unchecked") - ActionListener listener = (ActionListener) invocation.getArguments()[1]; - listener.onResponse(new OpenIndexResponse(true, true)); - return null; - }).when(indicesClient).open(Mockito.any(), Mockito.any()); - - Boolean[] completed = new Boolean[1]; - Exception[] failure = new Exception[1]; - OpenFollowerIndexStep step = new OpenFollowerIndexStep(randomStepKey(), randomStepKey(), client); - step.performAction(indexMetadata, emptyClusterState(), null, new AsyncActionStep.Listener() { - @Override - public void onResponse(boolean complete) { - completed[0] = complete; - } - - @Override - public void onFailure(Exception e) { - failure[0] = e; - } - }); - assertThat(completed[0], is(true)); - assertThat(failure[0], nullValue()); - } - - public void testOpenFollowingIndexFailed() { - IndexMetadata indexMetadata = IndexMetadata.builder("follower-index") - .settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_INDEXING_COMPLETE, "true")) - .state(IndexMetadata.State.CLOSE) - .putCustom(CCR_METADATA_KEY, Collections.emptyMap()) - .numberOfShards(1) - .numberOfReplicas(0) - .build(); - - Exception error = new RuntimeException(); - Mockito.doAnswer(invocation -> { - OpenIndexRequest closeIndexRequest = (OpenIndexRequest) invocation.getArguments()[0]; - assertThat(closeIndexRequest.indices()[0], equalTo("follower-index")); - ActionListener listener = (ActionListener) invocation.getArguments()[1]; - listener.onFailure(error); - return null; - }).when(indicesClient).open(Mockito.any(), Mockito.any()); - - Boolean[] completed = new Boolean[1]; - Exception[] failure = new Exception[1]; - OpenFollowerIndexStep step = new OpenFollowerIndexStep(randomStepKey(), randomStepKey(), client); - step.performAction(indexMetadata, emptyClusterState(), null, new AsyncActionStep.Listener() { - @Override - public void onResponse(boolean complete) { - completed[0] = complete; - } - - @Override - public void onFailure(Exception e) { - failure[0] = e; - } - }); - assertThat(completed[0], nullValue()); - assertThat(failure[0], sameInstance(error)); - Mockito.verify(indicesClient).open(Mockito.any(), Mockito.any()); - Mockito.verifyNoMoreInteractions(indicesClient); - } -} From 822691fc1ed3b666ddd112f53a52b6bc92c50738 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Wed, 10 Mar 2021 15:52:38 -0800 Subject: [PATCH 13/15] more fixes from precommit --- .../java/org/elasticsearch/xpack/core/search/PointInTimeIT.java | 1 + .../xpack/core/ml/inference/preprocessing/MultiTests.java | 1 + 2 files changed, 2 insertions(+) diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/search/PointInTimeIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/search/PointInTimeIT.java index 73e29626c7f82..82650583f2fca 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/search/PointInTimeIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/core/search/PointInTimeIT.java @@ -415,6 +415,7 @@ public void testPITTiebreak() throws Exception { } } + @SuppressWarnings({"rawtypes","unchecked"}) private void assertPagination(PointInTimeBuilder pit, int expectedNumDocs, int size, SortBuilder... sorts) throws Exception { Set seen = new HashSet<>(); SearchRequestBuilder builder = client().prepareSearch() diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java index f226cec21d19d..441cbd1b98e64 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java @@ -46,6 +46,7 @@ public static Multi createRandom() { return createRandom(randomBoolean() ? null : randomBoolean()); } + @SuppressWarnings("unchecked") public static Multi createRandom(Boolean isCustom) { final PreProcessor[] processors; if (isCustom == null || isCustom == false) { From 08c9bbc1af89044dce4c2753663eddd3b8fa0173 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Thu, 11 Mar 2021 13:37:28 -0800 Subject: [PATCH 14/15] resolve comments partial --- .../org/elasticsearch/xpack/core/ml/job/config/RuleScope.java | 2 +- .../elasticsearch/xpack/core/watcher/actions/ActionWrapper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java index 11ba81fee41da..256cfeca65582 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/RuleScope.java @@ -44,7 +44,7 @@ public static ContextParser parser(boolean ignoreUnknownFields) Map scope = new HashMap<>(); for (Map.Entry entry : unparsedScope.entrySet()) { try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - builder.map((Map) entry.getValue()); + builder.map((Map) entry.getValue()); try (XContentParser scopeParser = XContentFactory.xContent(builder.contentType()).createParser( NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, Strings.toString(builder))) { scope.put(entry.getKey(), filterRefParser.parse(scopeParser, null)); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java index 71cec15cdf75f..7b78b69b557f7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/actions/ActionWrapper.java @@ -175,7 +175,7 @@ public ActionWrapperResult execute(WatchExecutionContext ctx) { Object object = ObjectPath.eval(path, toMap(ctx)); int runs = 0; if (object instanceof Collection) { - Collection collection = Collection.class.cast(object); + Collection collection = (Collection) object; if (collection.isEmpty()) { throw new ElasticsearchException("foreach object [{}] was an empty list, could not run any action", path); } else { From ac39aaed4d2fa6550484ec4cd99fdc23cdf07a71 Mon Sep 17 00:00:00 2001 From: Varsha Muzumdar <48073424+vamuzumd@users.noreply.github.com> Date: Thu, 11 Mar 2021 15:27:01 -0800 Subject: [PATCH 15/15] eliminate unchecked suppressions for randomFrom by adding safevarargs --- .../src/main/java/org/elasticsearch/test/ESTestCase.java | 4 ++++ .../core/ml/dataframe/analyses/ClassificationTests.java | 1 - .../xpack/core/ml/dataframe/analyses/RegressionTests.java | 1 - .../ml/inference/InferenceToXContentCompressorTests.java | 1 - .../xpack/core/ml/inference/NamedXContentObjectsTests.java | 1 - .../xpack/core/ml/inference/TrainedModelConfigTests.java | 5 +---- .../xpack/core/ml/inference/TrainedModelDefinitionTests.java | 1 - .../xpack/core/ml/inference/preprocessing/MultiTests.java | 1 - .../ml/inference/trainedmodel/ensemble/EnsembleTests.java | 1 - .../xpack/core/security/action/role/PutRoleRequestTests.java | 1 - .../authz/privilege/ApplicationPrivilegeDescriptorTests.java | 2 -- .../security/authz/privilege/ApplicationPrivilegeTests.java | 2 -- 12 files changed, 5 insertions(+), 16 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index a18fd0d6bcd5d..cfadcb2b5cf36 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -713,11 +713,15 @@ public static int randomInt(int max) { } /** Pick a random object from the given array. The array must not be empty. */ + @SafeVarargs + @SuppressWarnings("varargs") public static T randomFrom(T... array) { return randomFrom(random(), array); } /** Pick a random object from the given array. The array must not be empty. */ + @SafeVarargs + @SuppressWarnings("varargs") public static T randomFrom(Random random, T... array) { return RandomPicks.randomFrom(random, array); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java index f30b65ff5369e..8dba910aabba3 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/ClassificationTests.java @@ -89,7 +89,6 @@ protected NamedWriteableRegistry getNamedWriteableRegistry() { return new NamedWriteableRegistry(entries); } - @SuppressWarnings({"unchecked"}) public static Classification createRandom() { String dependentVariableName = randomAlphaOfLength(10); BoostedTreeParams boostedTreeParams = BoostedTreeParamsTests.createRandom(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java index d8a105c9d5e27..dd501734b1d90 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/RegressionTests.java @@ -82,7 +82,6 @@ public static Regression createRandom() { return createRandom(BoostedTreeParamsTests.createRandom()); } - @SuppressWarnings({"unchecked"}) private static Regression createRandom(BoostedTreeParams boostedTreeParams) { String dependentVariableName = randomAlphaOfLength(10); String predictionFieldName = randomBoolean() ? null : randomAlphaOfLength(10); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java index b2efa52aa7411..47a131f5d758c 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressorTests.java @@ -22,7 +22,6 @@ import static org.hamcrest.Matchers.equalTo; -@SuppressWarnings({"unchecked"}) public class InferenceToXContentCompressorTests extends ESTestCase { public void testInflateAndDeflate() throws IOException { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java index bbb3cd4aab813..deebaa4c7297a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/NamedXContentObjectsTests.java @@ -147,7 +147,6 @@ public void chooseStrictOrLenient() { lenient = randomBoolean(); } - @SuppressWarnings({"unchecked"}) @Override public NamedObjectContainer createTestInstance() { int max = randomIntBetween(1, 10); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java index 9c1c85715d87b..a23220b69f8e0 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfigTests.java @@ -53,7 +53,6 @@ public class TrainedModelConfigTests extends AbstractBWCSerializationTestCase tags = Arrays.asList(generateRandomStringArray(randomIntBetween(0, 5), 15, false)); return TrainedModelConfig.builder() @@ -130,7 +129,6 @@ protected boolean assertToXContentEquivalence() { return false; } - @SuppressWarnings({"unchecked"}) public void testToXContentWithParams() throws IOException { TrainedModelConfig.LazyModelDefinition lazyModelDefinition = TrainedModelConfig.LazyModelDefinition .fromParsedDefinition(TrainedModelDefinitionTests.createRandomBuilder().build()); @@ -170,8 +168,7 @@ public void testToXContentWithParams() throws IOException { assertThat(reference.utf8ToString(), containsString("\"definition\"")); assertThat(reference.utf8ToString(), not(containsString("compressed_definition"))); } - - @SuppressWarnings({"unchecked"}) + public void testParseWithBothDefinitionAndCompressedSupplied() throws IOException { TrainedModelConfig.LazyModelDefinition lazyModelDefinition = TrainedModelConfig.LazyModelDefinition .fromParsedDefinition(TrainedModelDefinitionTests.createRandomBuilder().build()); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java index e37c063ea0a32..56a4eae17bcd1 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelDefinitionTests.java @@ -59,7 +59,6 @@ protected boolean assertToXContentEquivalence() { return false; } - @SuppressWarnings({"unchecked"}) public static TrainedModelDefinition.Builder createRandomBuilder(TargetType targetType) { int numberOfProcessors = randomIntBetween(1, 10); return new TrainedModelDefinition.Builder() diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java index 441cbd1b98e64..f226cec21d19d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/MultiTests.java @@ -46,7 +46,6 @@ public static Multi createRandom() { return createRandom(randomBoolean() ? null : randomBoolean()); } - @SuppressWarnings("unchecked") public static Multi createRandom(Boolean isCustom) { final PreProcessor[] processors; if (isCustom == null || isCustom == false) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java index 07f7654105bca..f531df541b6c6 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/ensemble/EnsembleTests.java @@ -65,7 +65,6 @@ public static Ensemble createRandom(TargetType targetType) { return createRandom(targetType, featureNames); } - @SuppressWarnings({"unchecked"}) public static Ensemble createRandom(TargetType targetType, List featureNames) { int numberOfModels = randomIntBetween(1, 10); List treeFeatureNames = featureNames.isEmpty() ? diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java index f4ffb89bda555..458cb91929a11 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/role/PutRoleRequestTests.java @@ -131,7 +131,6 @@ private PutRoleRequest buildRequestWithApplicationPrivilege(String appName, Stri return request; } - @SuppressWarnings("unchecked") private PutRoleRequest buildRandomRequest() { final PutRoleRequest request = new PutRoleRequest(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java index 71319bc3bd03f..6b420aa2397ef 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeDescriptorTests.java @@ -32,7 +32,6 @@ public class ApplicationPrivilegeDescriptorTests extends ESTestCase { - @SuppressWarnings("unchecked") public void testEqualsAndHashCode() { final ApplicationPrivilegeDescriptor privilege = randomPrivilege(); final EqualsHashCodeTestUtils.MutateFunction mutate = randomFrom( @@ -121,7 +120,6 @@ public void testParseXContentWithoutUsingDefaultNames() throws IOException { } } - @SuppressWarnings("unchecked") private ApplicationPrivilegeDescriptor randomPrivilege() { final String applicationName; if (randomBoolean()) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java index 9a10d9d43aed2..04e5077f6108d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/ApplicationPrivilegeTests.java @@ -151,7 +151,6 @@ private ApplicationPrivilegeDescriptor descriptor(String application, String nam return new ApplicationPrivilegeDescriptor(application, name, Sets.newHashSet(actions), Collections.emptyMap()); } - @SuppressWarnings("unchecked") public void testEqualsAndHashCode() { final ApplicationPrivilege privilege = randomPrivilege(); final EqualsHashCodeTestUtils.MutateFunction mutate = randomFrom( @@ -196,7 +195,6 @@ private void assertNoException(String reason, ThrowingRunnable body) { } } - @SuppressWarnings("unchecked") private ApplicationPrivilege randomPrivilege() { final String applicationName; if (randomBoolean()) {