Merge branch 'stable-5.11' into stable-5.12

* stable-5.11:
  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: I25bb99687b969f9915a7cbda8d1332bec778096a
This commit is contained in:
Matthias Sohn 2023-04-20 15:12:01 +02:00
commit f164bd988d
7 changed files with 89 additions and 7 deletions

View File

@ -1 +1 @@
-T 1C -T1C

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jgit.junit.ssh" version="2">
<resource path="src/org/eclipse/jgit/junit/ssh/SshTestHarness.java" type="org.eclipse.jgit.junit.ssh.SshTestHarness">
<filter id="336658481">
<message_arguments>
<message_argument value="org.eclipse.jgit.junit.ssh.SshTestHarness"/>
<message_argument value="publicKey2"/>
</resource>
<resource path="META-INF/MANIFEST.MF">
<filter id="923795461">
<message_arguments>
<message_argument value="5.11.2"/>
<message_argument value="5.10.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/jgit/junit/ssh/SshTestBase.java" type="org.eclipse.jgit.junit.ssh.SshTestBase">
<filter id="338792546">
<message_arguments>
<message_argument value="org.eclipse.jgit.junit.ssh.SshTestBase"/>
<message_argument value="testSshWithConfig()"/>
</message_arguments>
</filter>
</resource>
</component>

View File

@ -22,6 +22,8 @@
* Some minimal cloning and fetching tests. Concrete subclasses can implement * Some minimal cloning and fetching tests. Concrete subclasses can implement
* the abstract operations from {@link SshTestHarness} to run with different SSH * the abstract operations from {@link SshTestHarness} to run with different SSH
* implementations. * implementations.
*
* @since 5.11
*/ */
public abstract class SshBasicTestBase extends SshTestHarness { public abstract class SshBasicTestBase extends SshTestHarness {

View File

@ -76,6 +76,9 @@ public abstract class SshTestHarness extends RepositoryTestCase {
protected File publicKey1; protected File publicKey1;
/**
* @since 5.10
*/
protected File publicKey2; protected File publicKey2;
protected SshTestGitServer server; protected SshTestGitServer server;

View File

@ -18,6 +18,8 @@
public class PackMismatchException extends IOException { public class PackMismatchException extends IOException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private boolean permanent;
/** /**
* Construct a pack modification error. * Construct a pack modification error.
* *
@ -27,4 +29,31 @@ public class PackMismatchException extends IOException {
public PackMismatchException(String why) { public PackMismatchException(String why) {
super(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$
}
} }

View File

@ -30,6 +30,7 @@
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jgit.errors.PackMismatchException;
import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.pack.ObjectToPack; import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
import org.eclipse.jgit.internal.storage.pack.PackExt; import org.eclipse.jgit.internal.storage.pack.PackExt;
@ -350,7 +351,8 @@ private ObjectLoader openObjectWithoutRestoring(WindowCursor curs, AnyObjectId o
} }
private ObjectLoader openPackedFromSelfOrAlternate(WindowCursor curs, private ObjectLoader openPackedFromSelfOrAlternate(WindowCursor curs,
AnyObjectId objectId, Set<AlternateHandle.Id> skips) { AnyObjectId objectId, Set<AlternateHandle.Id> skips)
throws PackMismatchException {
ObjectLoader ldr = openPackedObject(curs, objectId); ObjectLoader ldr = openPackedObject(curs, objectId);
if (ldr != null) { if (ldr != null) {
return ldr; return ldr;
@ -386,7 +388,8 @@ private ObjectLoader openLooseFromSelfOrAlternate(WindowCursor curs,
return null; return null;
} }
ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId) { ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId)
throws PackMismatchException {
return packed.open(curs, objectId); return packed.open(curs, objectId);
} }
@ -421,7 +424,8 @@ private long getObjectSizeWithoutRestoring(WindowCursor curs,
} }
private long getPackedSizeFromSelfOrAlternate(WindowCursor curs, 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); long len = packed.getSize(curs, id);
if (0 <= len) { if (0 <= len) {
return len; return len;

View File

@ -59,6 +59,8 @@ class PackDirectory {
private final static Logger LOG = LoggerFactory private final static Logger LOG = LoggerFactory
.getLogger(PackDirectory.class); .getLogger(PackDirectory.class);
private static final int MAX_PACKLIST_RESCAN_ATTEMPTS = 5;
private static final PackList NO_PACKS = new PackList(FileSnapshot.DIRTY, private static final PackList NO_PACKS = new PackList(FileSnapshot.DIRTY,
new Pack[0]); new Pack[0]);
@ -201,9 +203,11 @@ boolean resolve(Set<ObjectId> matches, AbbreviatedObjectId id,
return true; return true;
} }
ObjectLoader open(WindowCursor curs, AnyObjectId objectId) { ObjectLoader open(WindowCursor curs, AnyObjectId objectId)
throws PackMismatchException {
PackList pList; PackList pList;
do { do {
int retries = 0;
SEARCH: for (;;) { SEARCH: for (;;) {
pList = packList.get(); pList = packList.get();
for (Pack p : pList.packs) { for (Pack p : pList.packs) {
@ -215,6 +219,7 @@ ObjectLoader open(WindowCursor curs, AnyObjectId objectId) {
} catch (PackMismatchException e) { } catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list. // Pack was modified; refresh the entire pack list.
if (searchPacksAgain(pList)) { if (searchPacksAgain(pList)) {
retries = checkRescanPackThreshold(retries, e);
continue SEARCH; continue SEARCH;
} }
} catch (IOException e) { } catch (IOException e) {
@ -227,9 +232,11 @@ ObjectLoader open(WindowCursor curs, AnyObjectId objectId) {
return null; return null;
} }
long getSize(WindowCursor curs, AnyObjectId id) { long getSize(WindowCursor curs, AnyObjectId id)
throws PackMismatchException {
PackList pList; PackList pList;
do { do {
int retries = 0;
SEARCH: for (;;) { SEARCH: for (;;) {
pList = packList.get(); pList = packList.get();
for (Pack p : pList.packs) { for (Pack p : pList.packs) {
@ -242,6 +249,7 @@ long getSize(WindowCursor curs, AnyObjectId id) {
} catch (PackMismatchException e) { } catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list. // Pack was modified; refresh the entire pack list.
if (searchPacksAgain(pList)) { if (searchPacksAgain(pList)) {
retries = checkRescanPackThreshold(retries, e);
continue SEARCH; continue SEARCH;
} }
} catch (IOException e) { } catch (IOException e) {
@ -255,8 +263,9 @@ long getSize(WindowCursor curs, AnyObjectId id) {
} }
void selectRepresentation(PackWriter packer, ObjectToPack otp, void selectRepresentation(PackWriter packer, ObjectToPack otp,
WindowCursor curs) { WindowCursor curs) throws PackMismatchException {
PackList pList = packList.get(); PackList pList = packList.get();
int retries = 0;
SEARCH: for (;;) { SEARCH: for (;;) {
for (Pack p : pList.packs) { for (Pack p : pList.packs) {
try { try {
@ -268,6 +277,7 @@ void selectRepresentation(PackWriter packer, ObjectToPack otp,
} catch (PackMismatchException e) { } catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list. // Pack was modified; refresh the entire pack list.
// //
retries = checkRescanPackThreshold(retries, e);
pList = scanPacks(pList); pList = scanPacks(pList);
continue SEARCH; continue SEARCH;
} catch (IOException e) { } catch (IOException e) {
@ -278,6 +288,15 @@ void selectRepresentation(PackWriter packer, ObjectToPack otp,
} }
} }
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) { private void handlePackError(IOException e, Pack p) {
String warnTmpl = null; String warnTmpl = null;
int transientErrorCount = 0; int transientErrorCount = 0;