summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorDariusz Luksza <dariusz.luksza@gmail.com>2024-02-12 09:56:36 +0000
committerDariusz Luksza <dariusz.luksza@gmail.com>2024-02-12 09:56:36 +0000
commit56d040b8c73c224aea19c6930bf0892b5b9aca1c (patch)
treef1fb2c4732bb92fd494b5c18f5b4f95412ca5faa /org.eclipse.jgit
parentb5bfa90a9e2deb13b5151e5d9885db741b2e7f7a (diff)
parent7476183589f4c255ea561be9dff0109fc8919e9f (diff)
downloadjgit-56d040b8c73c224aea19c6930bf0892b5b9aca1c.tar.gz
jgit-56d040b8c73c224aea19c6930bf0892b5b9aca1c.zip
Merge branch 'stable-6.6' into stable-6.7
* stable-6.6: Improve handling of NFS stale handle errors Fix handling of missing pack index file Add tests for handling pack files removal during fetch Change-Id: Ie00984319d68beeffcbdb6bb323fbeb94a118e5c
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java24
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java4
2 files changed, 23 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
index 90f9811679..4f1d348844 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
@@ -64,6 +64,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.util.Hex;
+import org.eclipse.jgit.util.FileUtils;
import org.eclipse.jgit.util.LongList;
import org.eclipse.jgit.util.NB;
import org.eclipse.jgit.util.RawParseUtils;
@@ -682,7 +683,12 @@ public class Pack implements Iterable<PackIndex.MutableEntry> {
// exceptions signaling permanent problems with a pack
openFail(true, pe);
throw pe;
- } catch (IOException | RuntimeException ge) {
+ } catch (IOException ioe) {
+ // mark this packfile as invalid when NFS stale file handle error
+ // occur
+ openFail(FileUtils.isStaleFileHandleInCausalChain(ioe), ioe);
+ throw ioe;
+ } catch (RuntimeException ge) {
// generic exceptions could be transient so we should not mark the
// pack invalid to avoid false MissingObjectExceptions
openFail(false, ge);
@@ -1153,9 +1159,19 @@ public class Pack implements Iterable<PackIndex.MutableEntry> {
return idx;
}
} catch (FileNotFoundException e) {
- // Once upon a time this bitmap file existed. Now it
- // has been removed. Most likely an external gc has
- // removed this packfile and the bitmap
+ // Once upon a time the bitmap or index files existed. Now one
+ // of them has been removed. Most likely an external gc has
+ // removed index, packfile or the bitmap
+ bitmapIdxFile = null;
+ return null;
+ } catch (IOException e) {
+ if (!FileUtils.isStaleFileHandleInCausalChain(e)) {
+ throw e;
+ }
+ // Ignore NFS stale handle exception the same way as
+ // FileNotFoundException above.
+ bitmapIdxFile = null;
+ return null;
}
bitmapIdxFile = null;
return null;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java
index 7778cb5133..d432a0349a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java
@@ -64,7 +64,9 @@ public abstract class PackIndex
public static PackIndex open(File idxFile) throws IOException {
try (SilentFileInputStream fd = new SilentFileInputStream(
idxFile)) {
- return read(fd);
+ return read(fd);
+ } catch (FileNotFoundException e) {
+ throw e;
} catch (IOException ioe) {
throw new IOException(
MessageFormat.format(JGitText.get().unreadablePackIndex,