From 3e9486f56d7d72f2cce8b19844a84ab5a6b597af Mon Sep 17 00:00:00 2001 From: Ludovic DEHON Date: Thu, 9 Mar 2023 13:50:31 +0100 Subject: [PATCH] fix(core): remove some compilation warning --- .../java/io/kestra/core/docs/JsonSchemaGenerator.java | 6 +++--- .../java/io/kestra/core/metrics/MetricRegistry.java | 11 ++++------- .../io/kestra/core/tasks/scripts/BashService.java | 2 +- core/src/main/java/io/kestra/core/utils/Debug.java | 1 + .../io/kestra/core/docs/JsonSchemaGeneratorTest.java | 1 + .../src/main/java/io/kestra/runner/h2/H2Queue.java | 3 ++- .../main/java/io/kestra/runner/mysql/MysqlQueue.java | 3 ++- .../java/io/kestra/runner/postgres/PostgresQueue.java | 3 ++- .../io/kestra/webserver/utils/AutocompleteUtils.java | 2 ++ 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java b/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java index 776170bbdab..996aedf5cfc 100644 --- a/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java +++ b/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java @@ -108,7 +108,7 @@ private void mutateDescription(ObjectNode collectedTypeAttributes) { @SuppressWarnings("unchecked") private static void fixFlow(Map map) { var definitions = (Map>) map.get("definitions"); - var flow = (Map) definitions.get("io.kestra.core.models.flows.Flow"); + var flow = definitions.get("io.kestra.core.models.flows.Flow"); var requireds = (List) flow.get("required"); requireds.remove("deleted"); @@ -120,7 +120,7 @@ private static void fixFlow(Map map) { @SuppressWarnings("unchecked") private static void fixTask(Map map) { var definitions = (Map>) map.get("definitions"); - var task = (Map) definitions.get("io.kestra.core.models.tasks.Task-2"); + var task = definitions.get("io.kestra.core.models.tasks.Task-2"); var allOf = (List) task.get("allOf"); allOf.remove(1); } @@ -128,7 +128,7 @@ private static void fixTask(Map map) { @SuppressWarnings("unchecked") private static void fixTrigger(Map map) { var definitions = (Map>) map.get("definitions"); - var task = (Map) definitions.get("io.kestra.core.models.triggers.AbstractTrigger-2"); + var task = definitions.get("io.kestra.core.models.triggers.AbstractTrigger-2"); var allOf = (List) task.get("allOf"); allOf.remove(1); } diff --git a/core/src/main/java/io/kestra/core/metrics/MetricRegistry.java b/core/src/main/java/io/kestra/core/metrics/MetricRegistry.java index 525c35bf1f5..1721700c3da 100644 --- a/core/src/main/java/io/kestra/core/metrics/MetricRegistry.java +++ b/core/src/main/java/io/kestra/core/metrics/MetricRegistry.java @@ -1,19 +1,17 @@ package io.kestra.core.metrics; -import io.micrometer.core.instrument.*; -import io.micrometer.core.instrument.binder.MeterBinder; -import io.micrometer.core.lang.Nullable; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ArrayUtils; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.triggers.TriggerContext; import io.kestra.core.runners.WorkerTask; import io.kestra.core.runners.WorkerTaskResult; import io.kestra.core.schedulers.SchedulerExecutionWithTrigger; - +import io.micrometer.core.instrument.*; +import io.micrometer.core.instrument.binder.MeterBinder; import jakarta.inject.Inject; import jakarta.inject.Singleton; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ArrayUtils; @Singleton @Slf4j @@ -89,7 +87,6 @@ public Counter counter(String name, String... tags) { * @return The number that was passed in so the registration can be done as part of an assignment * statement. */ - @Nullable public T gauge(String name, T number, String... tags) { return this.meterRegistry.gauge(metricName(name), Tags.of(tags), number); } diff --git a/core/src/main/java/io/kestra/core/tasks/scripts/BashService.java b/core/src/main/java/io/kestra/core/tasks/scripts/BashService.java index c1d43bb2bf0..db5a399e239 100644 --- a/core/src/main/java/io/kestra/core/tasks/scripts/BashService.java +++ b/core/src/main/java/io/kestra/core/tasks/scripts/BashService.java @@ -103,9 +103,9 @@ private static void validFilename(String s) { } } + @SuppressWarnings("unchecked") public static Map transformInputFiles(RunContext runContext, @NotNull Object inputFiles) throws IllegalVariableEvaluationException, JsonProcessingException { if (inputFiles instanceof Map) { - //noinspection unchecked return (Map) inputFiles; } else if (inputFiles instanceof String) { final TypeReference> reference = new TypeReference<>() {}; diff --git a/core/src/main/java/io/kestra/core/utils/Debug.java b/core/src/main/java/io/kestra/core/utils/Debug.java index db8967d4017..0004c89bf68 100644 --- a/core/src/main/java/io/kestra/core/utils/Debug.java +++ b/core/src/main/java/io/kestra/core/utils/Debug.java @@ -39,6 +39,7 @@ public static String toJson(T arg) { } @SafeVarargs + @SuppressWarnings("varargs") public static void log(T... args) { LOGGER.trace("\033[44;30m " + caller() + " \033[0m"); diff --git a/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java b/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java index 8390086b266..69869e91fa4 100644 --- a/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java +++ b/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java @@ -138,6 +138,7 @@ void bash() throws URISyntaxException { }); } + @SuppressWarnings("unchecked") @Test void testEnum() { Map generate = jsonSchemaGenerator.properties(Task.class, TaskWithEnum.class); diff --git a/jdbc-h2/src/main/java/io/kestra/runner/h2/H2Queue.java b/jdbc-h2/src/main/java/io/kestra/runner/h2/H2Queue.java index 6df7d19e1c1..1116c25fd3b 100644 --- a/jdbc-h2/src/main/java/io/kestra/runner/h2/H2Queue.java +++ b/jdbc-h2/src/main/java/io/kestra/runner/h2/H2Queue.java @@ -56,6 +56,7 @@ protected Result receiveFetch(DSLContext ctx, String consumerGroup) { .get(0); } + @SuppressWarnings("RedundantCast") @Override protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List offsets) { ctx @@ -68,7 +69,7 @@ protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List receiveFetch(DSLContext ctx, String consumerGroup) { .get(0); } + @SuppressWarnings("RedundantCast") @Override protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List offsets) { ctx @@ -66,7 +67,7 @@ protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List receiveFetch(DSLContext ctx, String consumerGroup) { .get(0); } + @SuppressWarnings("RedundantCast") @Override protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List offsets) { ctx @@ -82,7 +83,7 @@ protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List List map(Function map, List... lists) throws HttpStatusException { Stream stream = Stream.empty(); @@ -26,6 +27,7 @@ public static List map(Function map, List... lists) throws Ht } @SafeVarargs + @SuppressWarnings("varargs") public static List from(List... lists) throws HttpStatusException { return AutocompleteUtils .map(o -> o, lists);