Skip to content

Commit 662810b

Browse files
Fixes problems reported by spotbugs (#143)
1 parent b38f161 commit 662810b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/org/jenkinsci/plugins/buildnameupdater/BuildNameUpdater.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.File;
55
import java.io.FileReader;
66
import java.io.IOException;
7+
import java.nio.charset.StandardCharsets;
78
import java.util.logging.Level;
89
import java.util.logging.Logger;
910

@@ -18,7 +19,6 @@
1819
import hudson.tasks.BuildStepDescriptor;
1920
import hudson.tasks.Builder;
2021
import hudson.util.FormValidation;
21-
import jakarta.servlet.ServletException;
2222
import jenkins.MasterToSlaveFileCallable;
2323
import org.apache.commons.lang.StringUtils;
2424
import org.jenkinsci.plugins.buildnamesetter.Executor;
@@ -156,11 +156,11 @@ private static class FileCallable extends MasterToSlaveFileCallable<String> {
156156
private static final long serialVersionUID = 1L;
157157

158158
@Override
159-
@SuppressFBWarnings(value = "DM_DEFAULT_ENCODING", justification = "Rely on the default system encoding - legacy behavior")
160-
public String invoke(File file, VirtualChannel channel) throws IOException, InterruptedException {
159+
public String invoke(File file, VirtualChannel channel) throws IOException {
161160
if (file.getAbsoluteFile().exists()) {
162161
LOGGER.log(Level.INFO, "File is found, reading...");
163-
try (BufferedReader br = new BufferedReader(new FileReader(file.getAbsoluteFile()))) {
162+
try (BufferedReader br = new BufferedReader(
163+
new FileReader(file.getAbsoluteFile(), StandardCharsets.UTF_8))) {
164164
return br.readLine();
165165
}
166166
} else {
@@ -177,7 +177,7 @@ public DescriptorImpl() {
177177
}
178178

179179
@SuppressWarnings("unused")
180-
public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException {
180+
public FormValidation doCheckName(@QueryParameter String value) {
181181
if (value.isEmpty())
182182
return FormValidation.error("Please set a file path");
183183
return FormValidation.ok();

0 commit comments

Comments
 (0)