Skip to content

Commit

Permalink
Merge pull request #5205 from res0nance/minor-cleanup
Browse files Browse the repository at this point in the history
Minor cleanups to Fingerprint writing codepaths
  • Loading branch information
res0nance authored Jan 28, 2021
2 parents bfe36c1 + 15549a6 commit 022a09c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/model/Fingerprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ public RangeItem(String name, RangeSet ranges) {
* @deprecated Use {@link #addFor(hudson.model.Run)}
*/
@Deprecated
public synchronized void add(@NonNull AbstractBuild b) throws IOException {
public void add(@NonNull AbstractBuild b) throws IOException {
addFor(b);
}

Expand All @@ -1024,7 +1024,7 @@ public synchronized void add(@NonNull AbstractBuild b) throws IOException {
* @param b {@link Run} to be referenced in {@link #usages}
* @since 1.577
*/
public synchronized void addFor(@NonNull Run b) throws IOException {
public void addFor(@NonNull Run b) throws IOException {
add(b.getParent().getFullName(), b.getNumber());
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/util/AtomicFileWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
Expand Down Expand Up @@ -71,7 +72,7 @@ public class AtomicFileWriter extends Writer {
* Writes with UTF-8 encoding.
*/
public AtomicFileWriter(File f) throws IOException {
this(f,"UTF-8");
this(toPath(f), StandardCharsets.UTF_8);
}

/**
Expand All @@ -88,7 +89,7 @@ public AtomicFileWriter(@NonNull File f, @Nullable String encoding) throws IOExc
* Wraps potential {@link java.nio.file.InvalidPathException} thrown by {@link File#toPath()} in an
* {@link IOException} for backward compatibility.
*
* @param file
* @param file file to obtain the path of
* @return the path for that file
* @see File#toPath()
*/
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/util/FileChannelWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public class FileChannelWriter extends Writer {
* So we introduced this field to be able to still get a better integrity for the use case of {@link AtomicFileWriter}.
* Because from there, we make sure to call {@link #close()} from {@link AtomicFileWriter#commit()} anyway.
*/
private boolean forceOnFlush;
private final boolean forceOnFlush;

/**
* See forceOnFlush. You probably never want to set forceOnClose to false.
*/
private boolean forceOnClose;
private final boolean forceOnClose;

/**
* @param filePath the path of the file to write to.
Expand Down

0 comments on commit 022a09c

Please sign in to comment.