chore(core): fix various compilation warnings

Fixed clear Java compilation warnings.
This commit is contained in:
yuri1969
2025-01-29 21:47:03 +01:00
committed by Loïc Mathieu
parent e6827f2736
commit 625135959c
12 changed files with 21 additions and 26 deletions

View File

@@ -1,6 +1,5 @@
package io.kestra.cli.commands.plugins;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import io.kestra.cli.AbstractCommand;
import io.kestra.core.docs.DocumentationGenerator;
@@ -61,7 +60,7 @@ public class PluginDocCommand extends AbstractCommand {
Files
.asCharSink(
file,
Charsets.UTF_8
StandardCharsets.UTF_8
).write(s.getBody());
stdOut("Generate doc in: {0}", file);

View File

@@ -1,6 +1,5 @@
package io.kestra.core.docs;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import io.kestra.core.models.annotations.PluginSubGroup;
import io.kestra.core.models.conditions.Condition;
@@ -29,6 +28,7 @@ import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -257,7 +257,7 @@ public class DocumentationGenerator {
public static <T> String render(String templateName, Map<String, Object> vars) throws IOException {
String pebbleTemplate = IOUtils.toString(
Objects.requireNonNull(DocumentationGenerator.class.getClassLoader().getResourceAsStream("docs/" + templateName + ".peb")),
Charsets.UTF_8
StandardCharsets.UTF_8
);
PebbleTemplate compiledTemplate = pebbleEngine.getLiteralTemplate(pebbleTemplate);

View File

@@ -5,11 +5,14 @@ import io.kestra.core.models.tasks.Task;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
import java.io.Serial;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class KestraConstraintViolationException extends ConstraintViolationException {
@Serial
private static final long serialVersionUID = 1L;
public KestraConstraintViolationException(Set<? extends ConstraintViolation<?>> constraintViolations) {
super(constraintViolations);

View File

@@ -12,8 +12,8 @@ import io.pebbletemplates.pebble.extension.Filter;
import io.pebbletemplates.pebble.template.EvaluationContext;
import io.pebbletemplates.pebble.template.PebbleTemplate;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
@@ -31,10 +31,7 @@ public class UrlDecoderFilter implements Filter {
return null;
}
String arg = (String) input;
try {
arg = URLDecoder.decode(arg, "UTF-8");
} catch (UnsupportedEncodingException e) {
}
arg = URLDecoder.decode(arg, StandardCharsets.UTF_8);
return arg;
}

View File

@@ -1,8 +1,7 @@
package io.kestra.core.utils;
import com.google.common.base.Charsets;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hasher;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -62,6 +61,6 @@ public final class Hashing {
}
private static HashCode getHashString(String value) {
return com.google.common.hash.Hashing.murmur3_128().hashString(value, Charsets.UTF_8);
return com.google.common.hash.Hashing.murmur3_128().hashString(value, StandardCharsets.UTF_8);
}
}

View File

@@ -1,9 +1,9 @@
package io.kestra.core.utils;
import com.devskiller.friendly_id.FriendlyId;
import com.google.common.base.Charsets;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.UUID;
@@ -21,7 +21,7 @@ abstract public class IdUtils {
public static String from(String from) {
return FriendlyId.toFriendlyId(
UUID.nameUUIDFromBytes(
HASH_FUNCTION.hashString(from, Charsets.UTF_8).asBytes()
HASH_FUNCTION.hashString(from, StandardCharsets.UTF_8).asBytes()
)
);
}

View File

@@ -25,7 +25,7 @@ import java.util.Optional;
@Schema(
title = "Return a value for debugging purposes.",
description = """
This task is intended for troubleshooting.
This task is intended for troubleshooting.
It allows you to return templated values, inputs or outputs."""
)

View File

@@ -190,10 +190,10 @@ import java.util.Optional;
message: |
Full table name: {{parents[1].taskrun.value }}_{{parent.taskrun.value}}_{{taskrun.value}}
Direct/current loop (months): {{taskrun.value}}
Value of loop one higher up (years): {{parents[0].taskrun.value}}
Value of loop one higher up (years): {{parents[0].taskrun.value}}
Further up (table types): {{parents[1].taskrun.value}}
"""
),
),
}
)
public class ForEach extends Sequential implements FlowableTask<VoidOutput> {

View File

@@ -1,7 +1,6 @@
package io.kestra.core.http.client;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Charsets;
import com.google.common.net.HttpHeaders;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.http.HttpRequest;
@@ -420,7 +419,7 @@ class HttpClientTest {
try (var inputStream = fileUpload.getInputStream()) {
sink.next(new AbstractMap.SimpleEntry<>(
fileUpload.getName(),
IOUtils.toString(inputStream, Charsets.UTF_8)
IOUtils.toString(inputStream, StandardCharsets.UTF_8)
));
}
} catch (IOException e) {

View File

@@ -1,7 +1,6 @@
package io.kestra.plugin.core.http;
import com.devskiller.friendly_id.FriendlyId;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import io.kestra.core.http.client.HttpClientRequestException;
import io.kestra.core.http.client.HttpClientResponseException;
@@ -350,7 +349,7 @@ class RequestTest {
Request.Output output = task.run(runContext);
assertThat(output.getBody(), is("world > " + IOUtils.toString(new FileInputStream(file), Charsets.UTF_8)));
assertThat(output.getBody(), is("world > " + IOUtils.toString(new FileInputStream(file), StandardCharsets.UTF_8)));
assertThat(output.getCode(), is(200));
}
}
@@ -384,7 +383,7 @@ class RequestTest {
Request.Output output = task.run(runContext);
assertThat(output.getBody(), is("world > " + IOUtils.toString(new FileInputStream(file), Charsets.UTF_8)));
assertThat(output.getBody(), is("world > " + IOUtils.toString(new FileInputStream(file), StandardCharsets.UTF_8)));
assertThat(output.getCode(), is(200));
}
}

View File

@@ -1,7 +1,6 @@
package io.kestra.core.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import io.kestra.core.exceptions.DeserializationException;
import io.kestra.core.models.conditions.ConditionContext;
@@ -13,7 +12,6 @@ import io.kestra.core.models.flows.State;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.models.triggers.AbstractTrigger;
import io.kestra.core.models.triggers.Trigger;
import io.kestra.core.models.triggers.TriggerContext;
import io.kestra.core.queues.QueueInterface;
import io.kestra.core.repositories.LocalFlowRepositoryLoader;
import io.kestra.core.runners.DefaultRunContext;
@@ -26,6 +24,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.*;
@@ -44,7 +43,7 @@ abstract public class TestsUtils {
URL resource = TestsUtils.class.getClassLoader().getResource(path);
assert resource != null;
String read = Files.asCharSource(new File(resource.getFile()), Charsets.UTF_8).read();
String read = Files.asCharSource(new File(resource.getFile()), StandardCharsets.UTF_8).read();
return mapper.readValue(read, cls);
}

View File

@@ -60,7 +60,7 @@ public class StaticFilter implements HttpServerFilter {
.filter(n -> n.getFile().getAbsoluteFile().toString().endsWith("ui/index.html"))
.map(throwFunction(n -> IOUtils.toString(
Objects.requireNonNull(StaticFilter.class.getClassLoader().getResourceAsStream("ui/index.html")),
Charsets.UTF_8
StandardCharsets.UTF_8
)))
)
.filter(Optional::isPresent)