diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-04-21 00:40:02 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-04-21 00:45:30 +0200 |
commit | 06b40b95c2ac28595624e1672949d245aef11fe0 (patch) | |
tree | a0b4772f3dfa5d91f2346de919962d5f3c453b0a /org.eclipse.jgit | |
parent | 831da296d9c944bbea19789f2b88ebd477d00dd4 (diff) | |
parent | 6456059795c951f2b9261d50dc33d5902a5fbb87 (diff) | |
download | jgit-06b40b95c2ac28595624e1672949d245aef11fe0.tar.gz jgit-06b40b95c2ac28595624e1672949d245aef11fe0.zip |
Merge branch 'stable-6.4' into stable-6.5
* stable-6.4:
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: I89af76946014fb44bd64c20e2b01a53397768d90
Diffstat (limited to 'org.eclipse.jgit')
4 files changed, 86 insertions, 6 deletions
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters index b00ad4b22f..1fbc01102b 100644 --- a/org.eclipse.jgit/.settings/.api_filters +++ b/org.eclipse.jgit/.settings/.api_filters @@ -1,5 +1,19 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <component id="org.eclipse.jgit" version="2"> + <resource path="src/org/eclipse/jgit/errors/PackMismatchException.java" type="org.eclipse.jgit.errors.PackMismatchException"> + <filter id="1142947843"> + <message_arguments> + <message_argument value="5.9.1"/> + <message_argument value="isPermanent()"/> + </message_arguments> + </filter> + <filter id="1142947843"> + <message_arguments> + <message_argument value="5.9.1"/> + <message_argument value="setPermanent(boolean)"/> + </message_arguments> + </filter> + </resource> <resource path="src/org/eclipse/jgit/lib/BatchingProgressMonitor.java" type="org.eclipse.jgit.lib.BatchingProgressMonitor"> <filter id="336695337"> <message_arguments> @@ -79,6 +93,12 @@ </filter> <filter id="1142947843"> <message_arguments> + <message_argument value="5.13.2"/> + <message_argument value="CONFIG_KEY_SKIPHASH"/> + </message_arguments> + </filter> + <filter id="1142947843"> + <message_arguments> <message_argument value="6.1.1"/> <message_argument value="CONFIG_KEY_TRUST_PACKED_REFS_STAT"/> </message_arguments> @@ -150,6 +170,14 @@ </message_arguments> </filter> </resource> + <resource path="src/org/eclipse/jgit/revwalk/RevCommit.java" type="org.eclipse.jgit.revwalk.RevCommit"> + <filter id="1193279491"> + <message_arguments> + <message_argument value="6.5.1"/> + <message_argument value="buffer"/> + </message_arguments> + </filter> + </resource> <resource path="src/org/eclipse/jgit/storage/pack/PackConfig.java" type="org.eclipse.jgit.storage.pack.PackConfig"> <filter id="336658481"> <message_arguments> 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 e34167450d..f27daad897 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 @@ -32,6 +32,7 @@ import java.util.Optional; 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; @@ -380,7 +381,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; @@ -416,7 +418,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); } @@ -451,7 +454,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 a7f28c6778..6a99cb3d83 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]); @@ -209,9 +211,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) { @@ -223,6 +227,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) { @@ -235,9 +240,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) { @@ -250,6 +257,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) { @@ -263,8 +271,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 { @@ -279,6 +288,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) { @@ -289,6 +299,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; |