Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions core/src/main/java/hudson/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,11 @@ public static String loadFile(@Nonnull File logfile, @Nonnull Charset charset) t

StringBuilder str = new StringBuilder((int)logfile.length());

try (BufferedReader r = Files.newBufferedReader(logfile.toPath(), charset)) {
try (BufferedReader r = Files.newBufferedReader(fileToPath(logfile), charset)) {
char[] buf = new char[1024];
int len;
while ((len = r.read(buf, 0, buf.length)) > 0)
str.append(buf, 0, len);
} catch (InvalidPathException e) {
throw new IOException(e);
}

return str.toString();
Expand Down
5 changes: 1 addition & 4 deletions core/src/main/java/hudson/model/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import hudson.security.ACL;
import hudson.security.AccessControlled;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import jenkins.security.QueueItemAuthenticatorProvider;
import jenkins.util.Timer;
import hudson.triggers.SafeTimerTask;
Expand Down Expand Up @@ -377,15 +376,13 @@ public void load() {
// first try the old format
File queueFile = getQueueFile();
if (queueFile.exists()) {
try (BufferedReader in = Files.newBufferedReader(queueFile.toPath(), Charset.defaultCharset())) {
try (BufferedReader in = Files.newBufferedReader(Util.fileToPath(queueFile), Charset.defaultCharset())) {
String line;
while ((line = in.readLine()) != null) {
AbstractProject j = Jenkins.getInstance().getItemByFullName(line, AbstractProject.class);
if (j != null)
j.scheduleBuild();
}
} catch (InvalidPathException e) {
throw new IOException(e);
}
// discard the queue file now that we are done
queueFile.delete();
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/hudson/util/TextFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import com.google.common.collect.*;

import hudson.Util;

import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import javax.annotation.Nonnull;
Expand Down Expand Up @@ -69,12 +71,10 @@ public void delete() {
public String read() throws IOException {
StringWriter out = new StringWriter();
PrintWriter w = new PrintWriter(out);
try (BufferedReader in = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
try (BufferedReader in = Files.newBufferedReader(Util.fileToPath(file), StandardCharsets.UTF_8)) {
String line;
while ((line = in.readLine()) != null)
w.println(line);
} catch (InvalidPathException e) {
throw new IOException(e);
}
return out.toString();
}
Expand Down