Skip to content

Commit

Permalink
[JENKINS-75255] Tolerate AccessDeniedException in AtomicFileWriter (
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick authored Feb 15, 2025
1 parent a97d4d7 commit c2f6c00
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/hudson/util/AtomicFileWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.AccessDeniedException;
import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
Expand Down Expand Up @@ -246,11 +247,11 @@ private static void move(Path source, Path destination) throws IOException {
// Both files are on the same filesystem, so this should not happen.
LOGGER.log(Level.WARNING, e, () -> "Atomic move " + source + " → " + destination + " not supported. Falling back to non-atomic move.");
atomicMoveSupported = false;
} catch (AccessDeniedException e) {
LOGGER.log(Level.INFO, e, () -> "Move " + source + " → " + destination + " failed, perhaps due to a temporary file lock. Falling back to non-atomic move.");

Check warning on line 251 in core/src/main/java/hudson/util/AtomicFileWriter.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 250-251 are not covered by tests
}
}
if (!atomicMoveSupported) {
Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING);
}
Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING);
}

private static final class CleanupChecker implements Runnable {
Expand Down

0 comments on commit c2f6c00

Please sign in to comment.