Skip to content

Commit

Permalink
Merge pull request #185 from jglick/guava
Browse files Browse the repository at this point in the history
Unnecessary use of Guava in `StatusCheck`
  • Loading branch information
jtnord authored Jul 11, 2023
2 parents 8735d9e + 1c83074 commit 324450f
Showing 1 changed file with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

package org.jenkinsci.plugins.durabletask;

import com.google.common.io.Files;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.EnvVars;
import hudson.FilePath;
Expand Down Expand Up @@ -58,6 +55,7 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.security.MessageDigest;
Expand Down Expand Up @@ -386,20 +384,15 @@ static class StatusCheck extends MasterToSlaveFileCallable<Integer> {
@CheckForNull
public Integer invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
if (f.exists() && f.length() > 0) {
try {
String fileString = Files.readFirstLine(f, Charset.defaultCharset());
if (fileString == null || fileString.isEmpty()) {
return null;
} else {
fileString = fileString.trim();
if (fileString.isEmpty()) {
return null;
} else {
return Integer.parseInt(fileString);
}
String text = Files.readString(f.toPath(), Charset.defaultCharset()).trim();
if (text.isEmpty()) {
return null;
} else {
try {
return Integer.valueOf(text);
} catch (NumberFormatException x) {
throw new IOException("corrupted content in " + f + ": " + x, x);
}
} catch (NumberFormatException x) {
throw new IOException("corrupted content in " + f + ": " + x, x);
}
}
return null;
Expand Down

0 comments on commit 324450f

Please sign in to comment.