aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-04-20 15:40:36 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-04-20 16:00:30 +0200
commit393074368bbc8f461bf769470409d7d4ae081613 (patch)
tree56ff0753a7ad1ac25ab5d81a3d5aec037d43f69c /org.eclipse.jgit/src/org/eclipse
parentf73efea21f0dd1aefcf3aa1cd1a3718f2e598b34 (diff)
parentf164bd988d449756d0c4fe00ed650db5afaef78d (diff)
downloadjgit-393074368bbc8f461bf769470409d7d4ae081613.tar.gz
jgit-393074368bbc8f461bf769470409d7d4ae081613.zip
Merge branch 'stable-5.12' into stable-5.13
* stable-5.12: Add missing since tag for SshBasicTestBase Add missing since tag for SshTestHarness#publicKey2 Silence API errors Prevent infinite loop rescanning the pack list on PackMismatchException Remove blank in maven.config Change-Id: Ibe6652374ab5971105e62b05279f218c8c130fee
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java29
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java25
3 files changed, 58 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java
index 44b8e0193c..7a2c70de79 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java
@@ -18,6 +18,8 @@ import java.io.IOException;
public class PackMismatchException extends IOException {
private static final long serialVersionUID = 1L;
+ private boolean permanent;
+
/**
* Construct a pack modification error.
*
@@ -27,4 +29,31 @@ public class PackMismatchException extends IOException {
public PackMismatchException(String why) {
super(why);
}
+
+ /**
+ * Set the type of the exception
+ *
+ * @param permanent
+ * whether the exception is considered permanent
+ * @since 5.9.1
+ */
+ public void setPermanent(boolean permanent) {
+ this.permanent = permanent;
+ }
+
+ /**
+ * Check if this is a permanent problem
+ *
+ * @return if this is a permanent problem and repeatedly scanning the
+ * packlist couldn't fix it
+ * @since 5.9.1
+ */
+ public boolean isPermanent() {
+ return permanent;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + ", permanent: " + permanent; //$NON-NLS-1$
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
index 627facca02..a3ce3158ae 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
@@ -30,6 +30,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
+import org.eclipse.jgit.errors.PackMismatchException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
import org.eclipse.jgit.internal.storage.pack.PackExt;
@@ -350,7 +351,8 @@ public class ObjectDirectory extends FileObjectDatabase {
}
private ObjectLoader openPackedFromSelfOrAlternate(WindowCursor curs,
- AnyObjectId objectId, Set<AlternateHandle.Id> skips) {
+ AnyObjectId objectId, Set<AlternateHandle.Id> skips)
+ throws PackMismatchException {
ObjectLoader ldr = openPackedObject(curs, objectId);
if (ldr != null) {
return ldr;
@@ -386,7 +388,8 @@ public class ObjectDirectory extends FileObjectDatabase {
return null;
}
- ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId) {
+ ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId)
+ throws PackMismatchException {
return packed.open(curs, objectId);
}
@@ -421,7 +424,8 @@ public class ObjectDirectory extends FileObjectDatabase {
}
private long getPackedSizeFromSelfOrAlternate(WindowCursor curs,
- AnyObjectId id, Set<AlternateHandle.Id> skips) {
+ AnyObjectId id, Set<AlternateHandle.Id> skips)
+ throws PackMismatchException {
long len = packed.getSize(curs, id);
if (0 <= len) {
return len;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java
index f32909f44d..22977d3c03 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java
@@ -60,6 +60,8 @@ class PackDirectory {
private final static Logger LOG = LoggerFactory
.getLogger(PackDirectory.class);
+ private static final int MAX_PACKLIST_RESCAN_ATTEMPTS = 5;
+
private static final PackList NO_PACKS = new PackList(FileSnapshot.DIRTY,
new Pack[0]);
@@ -202,9 +204,11 @@ class PackDirectory {
return true;
}
- ObjectLoader open(WindowCursor curs, AnyObjectId objectId) {
+ ObjectLoader open(WindowCursor curs, AnyObjectId objectId)
+ throws PackMismatchException {
PackList pList;
do {
+ int retries = 0;
SEARCH: for (;;) {
pList = packList.get();
for (Pack p : pList.packs) {
@@ -216,6 +220,7 @@ class PackDirectory {
} catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list.
if (searchPacksAgain(pList)) {
+ retries = checkRescanPackThreshold(retries, e);
continue SEARCH;
}
} catch (IOException e) {
@@ -228,9 +233,11 @@ class PackDirectory {
return null;
}
- long getSize(WindowCursor curs, AnyObjectId id) {
+ long getSize(WindowCursor curs, AnyObjectId id)
+ throws PackMismatchException {
PackList pList;
do {
+ int retries = 0;
SEARCH: for (;;) {
pList = packList.get();
for (Pack p : pList.packs) {
@@ -243,6 +250,7 @@ class PackDirectory {
} catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list.
if (searchPacksAgain(pList)) {
+ retries = checkRescanPackThreshold(retries, e);
continue SEARCH;
}
} catch (IOException e) {
@@ -256,8 +264,9 @@ class PackDirectory {
}
void selectRepresentation(PackWriter packer, ObjectToPack otp,
- WindowCursor curs) {
+ WindowCursor curs) throws PackMismatchException {
PackList pList = packList.get();
+ int retries = 0;
SEARCH: for (;;) {
for (Pack p : pList.packs) {
try {
@@ -272,6 +281,7 @@ class PackDirectory {
} catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list.
//
+ retries = checkRescanPackThreshold(retries, e);
pList = scanPacks(pList);
continue SEARCH;
} catch (IOException e) {
@@ -282,6 +292,15 @@ class PackDirectory {
}
}
+ private int checkRescanPackThreshold(int retries, PackMismatchException e)
+ throws PackMismatchException {
+ if (retries++ > MAX_PACKLIST_RESCAN_ATTEMPTS) {
+ e.setPermanent(true);
+ throw e;
+ }
+ return retries;
+ }
+
private void handlePackError(IOException e, Pack p) {
String warnTmpl = null;
int transientErrorCount = 0;