commit | 9c02e2b02b926deef4e13bd0ed7629f5ee7b6aea | [log] [tgz] |
---|---|---|
author | Hector Oswaldo Caballero <hector.caballero@ericsson.com> | Thu Jun 25 11:38:54 2015 -0400 |
committer | Hector Oswaldo Caballero <hector.caballero@ericsson.com> | Fri Jun 26 11:28:32 2015 -0400 |
tree | fcc07781c36b4560cd918d12b139945eebae4f96 | |
parent | e3c37795d77ebb374ec4fe15dfe7cc3f6b37ca9c [diff] |
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()); }