aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-04-19 12:40:27 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-04-20 01:52:02 +0200
commitf33fd16425d8bbc0975d2e820ab0bc830015a48b (patch)
tree50db4ec02c29f5fd8ff50da52bc9aa1d9c7f216f /org.eclipse.jgit
parent08a5d2771d641b2f69e588ce11028d26323283aa (diff)
parent710d00b85e9419c7feaed71a1945351dab486f71 (diff)
downloadjgit-f33fd16425d8bbc0975d2e820ab0bc830015a48b.tar.gz
jgit-f33fd16425d8bbc0975d2e820ab0bc830015a48b.zip
Merge branch 'stable-5.0' into stable-5.1
* stable-5.0: Prepare 4.11.9-SNAPSHOT builds JGit v4.11.8.201904181247-r Prepare 4.9.11-SNAPSHOT builds JGit v4.9.10.201904181027-r Prepare 4.7.10-SNAPSHOT builds JGit v4.7.9.201904161809-r Prepare 4.5.8-SNAPSHOT builds JGit v4.5.7.201904151645-r Remember the cause for invalidating a packfile Fix API problem filters Fix pack files scan when filesnapshot isn't modified Change-Id: I685d8a797209bc1b9c1bb9caba40ac8713c6ce5b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/.settings/.api_filters16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java34
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/BlockBasedFile.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java11
-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.java20
6 files changed, 81 insertions, 28 deletions
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
index d6944f9450..fdacadf9a1 100644
--- a/org.eclipse.jgit/.settings/.api_filters
+++ b/org.eclipse.jgit/.settings/.api_filters
@@ -3,11 +3,25 @@
<resource path="META-INF/MANIFEST.MF">
<filter id="924844039">
<message_arguments>
- <message_argument value="5.1.6"/>
+ <message_argument value="5.1.7"/>
<message_argument value="5.1.0"/>
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/jgit/errors/PackInvalidException.java" type="org.eclipse.jgit.errors.PackInvalidException">
+ <filter id="1142947843">
+ <message_arguments>
+ <message_argument value="4.5.7"/>
+ <message_argument value="PackInvalidException(File, Throwable)"/>
+ </message_arguments>
+ </filter>
+ <filter id="1142947843">
+ <message_arguments>
+ <message_argument value="4.5.7"/>
+ <message_argument value="PackInvalidException(String, Throwable)"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/jgit/lib/GitmoduleEntry.java" type="org.eclipse.jgit.lib.GitmoduleEntry">
<filter id="1109393411">
<message_arguments>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java
index a83de06262..b238ab4718 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackInvalidException.java
@@ -60,9 +60,24 @@ public class PackInvalidException extends IOException {
*
* @param path
* path of the invalid pack file.
+ * @deprecated Use {@link #PackInvalidException(File, Throwable)}.
*/
+ @Deprecated
public PackInvalidException(File path) {
- this(path.getAbsolutePath());
+ this(path, null);
+ }
+
+ /**
+ * Construct a pack invalid error with cause.
+ *
+ * @param path
+ * path of the invalid pack file.
+ * @param cause
+ * cause of the pack file becoming invalid.
+ * @since 4.5.7
+ */
+ public PackInvalidException(File path, Throwable cause) {
+ this(path.getAbsolutePath(), cause);
}
/**
@@ -70,8 +85,23 @@ public class PackInvalidException extends IOException {
*
* @param path
* path of the invalid pack file.
+ * @deprecated Use {@link #PackInvalidException(String, Throwable)}.
*/
+ @Deprecated
public PackInvalidException(String path) {
- super(MessageFormat.format(JGitText.get().packFileInvalid, path));
+ this(path, null);
+ }
+
+ /**
+ * Construct a pack invalid error with cause.
+ *
+ * @param path
+ * path of the invalid pack file.
+ * @param cause
+ * cause of the pack file becoming invalid.
+ * @since 4.5.7
+ */
+ public PackInvalidException(String path, Throwable cause) {
+ super(MessageFormat.format(JGitText.get().packFileInvalid, path), cause);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/BlockBasedFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/BlockBasedFile.java
index b9758bd64e..58d12ab233 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/BlockBasedFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/BlockBasedFile.java
@@ -84,6 +84,9 @@ abstract class BlockBasedFile {
/** True once corruption has been detected that cannot be worked around. */
volatile boolean invalid;
+ /** Exception that caused the packfile to be flagged as invalid */
+ protected volatile Exception invalidatingCause;
+
BlockBasedFile(DfsBlockCache cache, DfsPackDescription desc, PackExt ext) {
this.cache = cache;
this.key = desc.getStreamKey(ext);
@@ -135,8 +138,9 @@ abstract class BlockBasedFile {
DfsBlock readOneBlock(long pos, DfsReader ctx,
@Nullable ReadableChannel fileChannel) throws IOException {
- if (invalid)
- throw new PackInvalidException(getFileName());
+ if (invalid) {
+ throw new PackInvalidException(getFileName(), invalidatingCause);
+ }
ctx.stats.readBlock++;
long start = System.nanoTime();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
index 05b8f61a42..c131f9457e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
@@ -181,8 +181,9 @@ public final class DfsPackFile extends BlockBasedFile {
return idx;
}
- if (invalid)
- throw new PackInvalidException(getFileName());
+ if (invalid) {
+ throw new PackInvalidException(getFileName(), invalidatingCause);
+ }
Repository.getGlobalListenerList()
.dispatch(new BeforeDfsPackIndexLoadedEvent(this));
@@ -224,11 +225,13 @@ public final class DfsPackFile extends BlockBasedFile {
}
} catch (EOFException e) {
invalid = true;
+ invalidatingCause = e;
throw new IOException(MessageFormat.format(
DfsText.get().shortReadOfIndex,
desc.getFileName(INDEX)), e);
} catch (IOException e) {
invalid = true;
+ invalidatingCause = e;
throw new IOException(MessageFormat.format(
DfsText.get().cannotReadIndex,
desc.getFileName(INDEX)), e);
@@ -720,8 +723,10 @@ public final class DfsPackFile extends BlockBasedFile {
private IOException packfileIsTruncated() {
invalid = true;
- return new IOException(MessageFormat.format(
+ IOException exc = new IOException(MessageFormat.format(
JGitText.get().packfileIsTruncated, getFileName()));
+ invalidatingCause = exc;
+ return exc;
}
private void readFully(long position, byte[] dstbuf, int dstoff, int cnt,
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 df67d79ed0..38e822ea7d 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.
*
@@ -674,13 +674,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
@@ -767,7 +762,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
@@ -917,7 +912,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;
}
@@ -1074,7 +1070,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 ee3c0a8dd9..d834b1a729 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();
@@ -184,7 +186,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
idx = loadedIdx;
if (idx == null) {
if (invalid) {
- throw new PackInvalidException(packFile);
+ throw new PackInvalidException(packFile, invalidatingCause);
}
try {
idx = PackIndex.open(extFile(INDEX));
@@ -208,6 +210,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
throw e;
} catch (IOException e) {
invalid = true;
+ invalidatingCause = e;
throw e;
}
}
@@ -661,7 +664,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) {
@@ -671,13 +674,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
@@ -685,20 +688,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();
}
@@ -725,7 +729,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);