Skip to content

Commit

Permalink
chore(core): fix various compilation warnings
Browse files Browse the repository at this point in the history
Fixed clear Java compilation warnings.
  • Loading branch information
yuri1969 authored and loicmathieu committed Feb 3, 2025
1 parent e6827f2 commit 6251359
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -61,7 +60,7 @@ public Integer call() throws Exception {
Files
.asCharSink(
file,
Charsets.UTF_8
StandardCharsets.UTF_8
).write(s.getBody());
stdOut("Generate doc in: {0}", file);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -29,6 +28,7 @@

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;
Expand Down Expand Up @@ -257,7 +257,7 @@ public static <T> String render(AbstractClassDocumentation<T> classInputDocument
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
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;

Expand All @@ -31,10 +31,7 @@ public Object apply(Object input, Map<String, Object> args, PebbleTemplate self,
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;
}

Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/io/kestra/core/utils/Hashing.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -62,6 +61,6 @@ public static byte[] decodeHexToBytes(final String value) {
}

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);
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/io/kestra/core/utils/IdUtils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +21,7 @@ public static String create() {
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()
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/io/kestra/plugin/core/debug/Return.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@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."""
)
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/io/kestra/plugin/core/flow/ForEach.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ It generates structured identifiers (e.g., `bucket1_2025_March`) by combining va
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> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -420,7 +419,7 @@ public io.micronaut.http.HttpResponse<Object> multipartPost(@Body MultipartBody
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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -350,7 +349,7 @@ void multipart() throws Exception {

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));
}
}
Expand Down Expand Up @@ -384,7 +383,7 @@ void multipartCustomFilename() throws Exception {

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));
}
}
Expand Down
5 changes: 2 additions & 3 deletions tests/src/main/java/io/kestra/core/utils/TestsUtils.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,7 +12,6 @@
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;
Expand All @@ -26,6 +24,7 @@
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.*;
Expand All @@ -44,7 +43,7 @@ public static <T> T map(String path, Class<T> cls) throws IOException {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, Server
.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)
Expand Down

0 comments on commit 6251359

Please sign in to comment.