Verify file existence before deleting it When creating a cached session file, a temporary file is generated; this file is then renamed to the final cache file name. Afterwards, when trying to erase this temporary file, a warning log entry is written because the delete operation fails (the file does not exist anymore giving it was renamed). Fix this by verifying a file exists before trying to delete it. Change-Id: If7e6435ccfbd5806a3167c6f07087a1082527628
diff --git a/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java b/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java index eefdd86..11e5b78 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java +++ b/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java
@@ -227,7 +227,7 @@ } private void deleteFile(File f) { - if (!f.delete()) { + if (f.exists() && !f.delete()) { log.warn("Cannot delete file " + f.getName() + " from cache " + dir.getAbsolutePath()); }