diff options
author | Luca Milanesio <luca.milanesio@gmail.com> | 2017-03-24 00:18:12 +0000 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-03-25 01:33:18 +0100 |
commit | 363a3657b133ea4668bd832410eff67cfdb7dfd1 (patch) | |
tree | fd504cb21912c9e9f7924bd62bc8cc0ff646f8eb /org.eclipse.jgit | |
parent | 11a12ceb0be1bf13e2e6d5de2368688a58f9400c (diff) | |
download | jgit-363a3657b133ea4668bd832410eff67cfdb7dfd1.tar.gz jgit-363a3657b133ea4668bd832410eff67cfdb7dfd1.zip |
Don't flag a packfile invalid if opening existing file failed
A packfile random file open operation may fail with a
FileNotFoundException even if the file exists, possibly
for the temporary lack of resources.
Instead of managing the FileNotFoundException as any generic
IOException it is best to rethrow the exception but prevent
the packfile for being flagged as invalid until it is actually
opened and read successfully or unsuccessfully.
Bug: 514170
Change-Id: Ie37edba2df77052bceafc0b314fd1d487544bf35
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java index e004f90902..d33148152f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java @@ -50,6 +50,7 @@ import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX; import java.io.EOFException; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InterruptedIOException; import java.io.RandomAccessFile; @@ -635,6 +636,12 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> { // don't invalidate the pack, we are interrupted from another thread openFail(false); throw e; + } catch (FileNotFoundException fn) { + // don't invalidate the pack if opening an existing file failed + // since it may be related to a temporary lack of resources (e.g. + // max open files) + openFail(!packFile.exists()); + throw fn; } catch (IOException ioe) { openFail(true); throw ioe; |