Merge branch 'stable-5.9' into stable-5.10
* stable-5.9: Prevent infinite loop rescanning the pack list on PackMismatchException Remove blank in maven.config Change-Id: I15ff2d7716ecaceb0eb87b8823d85670f5db709d
This commit is contained in:
commit
26865d5a84
|
@ -1 +1 @@
|
|||
-T 1C
|
||||
-T1C
|
||||
|
|
|
@ -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/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
|
||||
<filter id="1141899266">
|
||||
<message_arguments>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
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$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ public class ObjectDirectory extends FileObjectDatabase {
|
|||
* handle exception is thrown */
|
||||
final static int MAX_LOOSE_OBJECT_STALE_READ_ATTEMPTS = 5;
|
||||
|
||||
private static final int MAX_PACKLIST_RESCAN_ATTEMPTS = 5;
|
||||
|
||||
private final AlternateHandle handle = new AlternateHandle(this);
|
||||
|
||||
private final Config config;
|
||||
|
@ -413,7 +415,8 @@ ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -449,9 +452,11 @@ private ObjectLoader openLooseFromSelfOrAlternate(WindowCursor curs,
|
|||
return null;
|
||||
}
|
||||
|
||||
ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId) {
|
||||
ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId)
|
||||
throws PackMismatchException {
|
||||
PackList pList;
|
||||
do {
|
||||
int retries = 0;
|
||||
SEARCH: for (;;) {
|
||||
pList = packList.get();
|
||||
for (PackFile p : pList.packs) {
|
||||
|
@ -462,8 +467,10 @@ ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId) {
|
|||
return ldr;
|
||||
} catch (PackMismatchException e) {
|
||||
// Pack was modified; refresh the entire pack list.
|
||||
if (searchPacksAgain(pList))
|
||||
if (searchPacksAgain(pList)) {
|
||||
retries = checkRescanPackThreshold(retries, e);
|
||||
continue SEARCH;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
handlePackError(e, p);
|
||||
}
|
||||
|
@ -555,7 +562,8 @@ long getObjectSize(WindowCursor curs, AnyObjectId id)
|
|||
}
|
||||
|
||||
private long getPackedSizeFromSelfOrAlternate(WindowCursor curs,
|
||||
AnyObjectId id, Set<AlternateHandle.Id> skips) {
|
||||
AnyObjectId id, Set<AlternateHandle.Id> skips)
|
||||
throws PackMismatchException {
|
||||
long len = getPackedObjectSize(curs, id);
|
||||
if (0 <= len) {
|
||||
return len;
|
||||
|
@ -590,9 +598,11 @@ private long getLooseSizeFromSelfOrAlternate(WindowCursor curs,
|
|||
return -1;
|
||||
}
|
||||
|
||||
private long getPackedObjectSize(WindowCursor curs, AnyObjectId id) {
|
||||
private long getPackedObjectSize(WindowCursor curs, AnyObjectId id)
|
||||
throws PackMismatchException {
|
||||
PackList pList;
|
||||
do {
|
||||
int retries = 0;
|
||||
SEARCH: for (;;) {
|
||||
pList = packList.get();
|
||||
for (PackFile p : pList.packs) {
|
||||
|
@ -603,8 +613,10 @@ private long getPackedObjectSize(WindowCursor curs, AnyObjectId id) {
|
|||
return len;
|
||||
} catch (PackMismatchException e) {
|
||||
// Pack was modified; refresh the entire pack list.
|
||||
if (searchPacksAgain(pList))
|
||||
if (searchPacksAgain(pList)) {
|
||||
retries = checkRescanPackThreshold(retries, e);
|
||||
continue SEARCH;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
handlePackError(e, p);
|
||||
}
|
||||
|
@ -639,6 +651,7 @@ void selectObjectRepresentation(PackWriter packer, ObjectToPack otp,
|
|||
private void selectObjectRepresentation(PackWriter packer, ObjectToPack otp,
|
||||
WindowCursor curs, Set<AlternateHandle.Id> skips) throws IOException {
|
||||
PackList pList = packList.get();
|
||||
int retries = 0;
|
||||
SEARCH: for (;;) {
|
||||
for (PackFile p : pList.packs) {
|
||||
try {
|
||||
|
@ -649,6 +662,7 @@ private void selectObjectRepresentation(PackWriter packer, ObjectToPack otp,
|
|||
} catch (PackMismatchException e) {
|
||||
// Pack was modified; refresh the entire pack list.
|
||||
//
|
||||
retries = checkRescanPackThreshold(retries, e);
|
||||
pList = scanPacks(pList);
|
||||
continue SEARCH;
|
||||
} catch (IOException e) {
|
||||
|
@ -666,6 +680,15 @@ private void selectObjectRepresentation(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, PackFile p) {
|
||||
String warnTmpl = null;
|
||||
int transientErrorCount = 0;
|
||||
|
|
Loading…
Reference in New Issue