Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java23
2 files changed, 22 insertions, 21 deletions
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 6ae559a085..740d515f69 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
@@ -132,8 +132,6 @@ public class ObjectDirectory extends FileObjectDatabase {
private final File alternatesFile;
- private final AtomicReference<PackList> packList;
-
private final FS fs;
private final AtomicReference<AlternateHandle[]> alternates;
@@ -146,6 +144,8 @@ public class ObjectDirectory extends FileObjectDatabase {
private Set<ObjectId> shallowCommitsIds;
+ final AtomicReference<PackList> packList;
+
/**
* Initialize a reference to an on-disk object directory.
*
@@ -654,13 +654,8 @@ public class ObjectDirectory extends FileObjectDatabase {
transientErrorCount = p.incrementTransientErrorCount();
}
if (warnTmpl != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(MessageFormat.format(warnTmpl,
- p.getPackFile().getAbsolutePath()), e);
- } else {
- LOG.warn(MessageFormat.format(warnTmpl,
- p.getPackFile().getAbsolutePath()));
- }
+ LOG.warn(MessageFormat.format(warnTmpl,
+ p.getPackFile().getAbsolutePath()), e);
} else {
if (doLogExponentialBackoff(transientErrorCount)) {
// Don't remove the pack from the list, as the error may be
@@ -747,7 +742,7 @@ public class ObjectDirectory extends FileObjectDatabase {
return InsertLooseObjectResult.FAILURE;
}
- private boolean searchPacksAgain(PackList old) {
+ boolean searchPacksAgain(PackList old) {
// Whether to trust the pack folder's modification time. If set
// to false we will always scan the .git/objects/pack folder to
// check for new pack files. If set to true (default) we use the
@@ -902,7 +897,8 @@ public class ObjectDirectory extends FileObjectDatabase {
final String packName = base + PACK.getExtension();
final File packFile = new File(packDirectory, packName);
final PackFile oldPack = forReuse.remove(packName);
- if (oldPack != null && oldPack.getFileSnapshot().isModified(packFile)) {
+ if (oldPack != null
+ && !oldPack.getFileSnapshot().isModified(packFile)) {
list.add(oldPack);
continue;
}
@@ -1049,7 +1045,7 @@ public class ObjectDirectory extends FileObjectDatabase {
return new File(new File(getDirectory(), d), f);
}
- private static final class PackList {
+ static final class PackList {
/** State just before reading the pack directory. */
final FileSnapshot snapshot;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
index e7db11d08c..c4e0d66c35 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
@@ -135,6 +135,8 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
private volatile boolean invalid;
+ private volatile Exception invalidatingCause;
+
private boolean invalidBitmap;
private AtomicInteger transientErrorCount = new AtomicInteger();
@@ -179,8 +181,9 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
private synchronized PackIndex idx() throws IOException {
if (loadedIdx == null) {
- if (invalid)
- throw new PackInvalidException(packFile);
+ if (invalid) {
+ throw new PackInvalidException(packFile, invalidatingCause);
+ }
try {
final PackIndex idx = PackIndex.open(extFile(INDEX));
@@ -198,6 +201,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
throw e;
} catch (IOException e) {
invalid = true;
+ invalidatingCause = e;
throw e;
}
}
@@ -647,7 +651,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
private void doOpen() throws IOException {
if (invalid) {
- throw new PackInvalidException(packFile);
+ throw new PackInvalidException(packFile, invalidatingCause);
}
try {
synchronized (readLock) {
@@ -657,13 +661,13 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
}
} catch (InterruptedIOException e) {
// don't invalidate the pack, we are interrupted from another thread
- openFail(false);
+ openFail(false, e);
throw e;
} catch (FileNotFoundException fn) {
// don't invalidate the pack if opening an existing file failed
// since it may be related to a temporary lack of resources (e.g.
// max open files)
- openFail(!packFile.exists());
+ openFail(!packFile.exists(), fn);
throw fn;
} catch (EOFException | AccessDeniedException | NoSuchFileException
| CorruptObjectException | NoPackSignatureException
@@ -671,20 +675,21 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
| UnsupportedPackIndexVersionException
| UnsupportedPackVersionException pe) {
// exceptions signaling permanent problems with a pack
- openFail(true);
+ openFail(true, pe);
throw pe;
} catch (IOException | RuntimeException ge) {
// generic exceptions could be transient so we should not mark the
// pack invalid to avoid false MissingObjectExceptions
- openFail(false);
+ openFail(false, ge);
throw ge;
}
}
- private void openFail(boolean invalidate) {
+ private void openFail(boolean invalidate, Exception cause) {
activeWindows = 0;
activeCopyRawData = 0;
invalid = invalidate;
+ invalidatingCause = cause;
doClose();
}
@@ -711,7 +716,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
// Detect the situation and throw a proper exception so that can be properly
// managed by the main packfile search loop and the Git client won't receive
// any failures.
- throw new PackInvalidException(packFile);
+ throw new PackInvalidException(packFile, invalidatingCause);
}
if (length < pos + size)
size = (int) (length - pos);

Back to the top