Skip to content

Commit

Permalink
fix(core): remove some compilation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Mar 9, 2023
1 parent 2f675fb commit 3e9486f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void mutateDescription(ObjectNode collectedTypeAttributes) {
@SuppressWarnings("unchecked")
private static void fixFlow(Map<String, Object> map) {
var definitions = (Map<String, Map<String, Object>>) map.get("definitions");
var flow = (Map<String, Object>) definitions.get("io.kestra.core.models.flows.Flow");
var flow = definitions.get("io.kestra.core.models.flows.Flow");

var requireds = (List<String>) flow.get("required");
requireds.remove("deleted");
Expand All @@ -120,15 +120,15 @@ private static void fixFlow(Map<String, Object> map) {
@SuppressWarnings("unchecked")
private static void fixTask(Map<String, Object> map) {
var definitions = (Map<String, Map<String, Object>>) map.get("definitions");
var task = (Map<String, Object>) definitions.get("io.kestra.core.models.tasks.Task-2");
var task = definitions.get("io.kestra.core.models.tasks.Task-2");
var allOf = (List<Object>) task.get("allOf");
allOf.remove(1);
}

@SuppressWarnings("unchecked")
private static void fixTrigger(Map<String, Object> map) {
var definitions = (Map<String, Map<String, Object>>) map.get("definitions");
var task = (Map<String, Object>) definitions.get("io.kestra.core.models.triggers.AbstractTrigger-2");
var task = definitions.get("io.kestra.core.models.triggers.AbstractTrigger-2");
var allOf = (List<Object>) task.get("allOf");
allOf.remove(1);
}
Expand Down
11 changes: 4 additions & 7 deletions core/src/main/java/io/kestra/core/metrics/MetricRegistry.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 extends Number> T gauge(String name, T number, String... tags) {
return this.meterRegistry.gauge(metricName(name), Tags.of(tags), number);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ private static void validFilename(String s) {
}
}

@SuppressWarnings("unchecked")
public static Map<String, String> transformInputFiles(RunContext runContext, @NotNull Object inputFiles) throws IllegalVariableEvaluationException, JsonProcessingException {
if (inputFiles instanceof Map) {
//noinspection unchecked
return (Map<String, String>) inputFiles;
} else if (inputFiles instanceof String) {
final TypeReference<Map<String, String>> reference = new TypeReference<>() {};
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/io/kestra/core/utils/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static <T> String toJson(T arg) {
}

@SafeVarargs
@SuppressWarnings("varargs")
public static <T> void log(T... args) {
LOGGER.trace("\033[44;30m " + caller() + " \033[0m");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void bash() throws URISyntaxException {
});
}

@SuppressWarnings("unchecked")
@Test
void testEnum() {
Map<String, Object> generate = jsonSchemaGenerator.properties(Task.class, TaskWithEnum.class);
Expand Down
3 changes: 2 additions & 1 deletion jdbc-h2/src/main/java/io/kestra/runner/h2/H2Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ protected Result<Record> receiveFetch(DSLContext ctx, String consumerGroup) {
.get(0);
}

@SuppressWarnings("RedundantCast")
@Override
protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List<Integer> offsets) {
ctx
Expand All @@ -68,7 +69,7 @@ protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List<Int
(Object) new String[]{consumerGroup}
)
)
.where(AbstractJdbcRepository.field("offset").in(offsets.toArray(Integer[]::new)))
.where(AbstractJdbcRepository.field("offset").in((Object[]) offsets.toArray(Integer[]::new)))
.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected Result<Record> receiveFetch(DSLContext ctx, String consumerGroup) {
.get(0);
}

@SuppressWarnings("RedundantCast")
@Override
protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List<Integer> offsets) {
ctx
Expand All @@ -66,7 +67,7 @@ protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List<Int
AbstractJdbcRepository.field("consumers"),
DSL.field("CONCAT_WS(',', consumers, ?)", String.class, consumerGroup)
)
.where(AbstractJdbcRepository.field("offset").in(offsets.toArray(Integer[]::new)))
.where(AbstractJdbcRepository.field("offset").in((Object[]) offsets.toArray(Integer[]::new)))
.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected Result<Record> receiveFetch(DSLContext ctx, String consumerGroup) {
.get(0);
}

@SuppressWarnings("RedundantCast")
@Override
protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List<Integer> offsets) {
ctx
Expand All @@ -82,7 +83,7 @@ protected void updateGroupOffsets(DSLContext ctx, String consumerGroup, List<Int
AbstractJdbcRepository.field("consumer_" + consumerGroup),
true
)
.where(AbstractJdbcRepository.field("offset").in(offsets.toArray(Integer[]::new)))
.where(AbstractJdbcRepository.field("offset").in((Object[]) offsets.toArray(Integer[]::new)))
.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class AutocompleteUtils {
@SafeVarargs
@SuppressWarnings("varargs")
public static <T, R> List<R> map(Function<T, R> map, List<T>... lists) throws HttpStatusException {
Stream<T> stream = Stream.empty();

Expand All @@ -26,6 +27,7 @@ public static <T, R> List<R> map(Function<T, R> map, List<T>... lists) throws Ht
}

@SafeVarargs
@SuppressWarnings("varargs")
public static <T> List<T> from(List<T>... lists) throws HttpStatusException {
return AutocompleteUtils
.map(o -> o, lists);
Expand Down

0 comments on commit 3e9486f

Please sign in to comment.