mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-06 16:45:58 +00:00
Merge pull request #3989 from olivergondza/afw-suppressed
Changed exception presented when AtomicFileWriter fails to write to file
This commit is contained in:
1 file changed
+10
-10
@@ -189,13 +189,13 @@ public class AtomicFileWriter extends Writer {
|
||||
try {
|
||||
// Try to make an atomic move.
|
||||
Files.move(tmpPath, destPath, StandardCopyOption.ATOMIC_MOVE);
|
||||
} catch (IOException e) {
|
||||
} catch (IOException moveFailed) {
|
||||
// If it falls here that can mean many things. Either that the atomic move is not supported,
|
||||
// or something wrong happened. Anyway, let's try to be over-diagnosing
|
||||
if (e instanceof AtomicMoveNotSupportedException) {
|
||||
LOGGER.log(Level.WARNING, "Atomic move not supported. falling back to non-atomic move.", e);
|
||||
if (moveFailed instanceof AtomicMoveNotSupportedException) {
|
||||
LOGGER.log(Level.WARNING, "Atomic move not supported. falling back to non-atomic move.", moveFailed);
|
||||
} else {
|
||||
LOGGER.log(Level.WARNING, "Unable to move atomically, falling back to non-atomic move.", e);
|
||||
LOGGER.log(Level.WARNING, "Unable to move atomically, falling back to non-atomic move.", moveFailed);
|
||||
}
|
||||
|
||||
if (destPath.toFile().exists()) {
|
||||
@@ -204,19 +204,19 @@ public class AtomicFileWriter extends Writer {
|
||||
|
||||
try {
|
||||
Files.move(tmpPath, destPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e1) {
|
||||
e1.addSuppressed(e);
|
||||
} catch (IOException replaceFailed) {
|
||||
replaceFailed.addSuppressed(moveFailed);
|
||||
LOGGER.log(Level.WARNING, "Unable to move {0} to {1}. Attempting to delete {0} and abandoning.",
|
||||
new Path[]{tmpPath, destPath});
|
||||
try {
|
||||
Files.deleteIfExists(tmpPath);
|
||||
} catch (IOException e2) {
|
||||
e2.addSuppressed(e1);
|
||||
} catch (IOException deleteFailed) {
|
||||
replaceFailed.addSuppressed(deleteFailed);
|
||||
LOGGER.log(Level.WARNING, "Unable to delete {0}, good bye then!", tmpPath);
|
||||
throw e2;
|
||||
throw replaceFailed;
|
||||
}
|
||||
|
||||
throw e1;
|
||||
throw replaceFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user