Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio2019-03-06 06:30:07 -0500
committerMatthias Sohn2019-03-12 10:06:05 -0400
commitafef866a44cd65fef292c174cad445b3fb526400 (patch)
tree2f8b048243feae66f1bb98b365127a7ae661ee51
parent2d116cd0ab5f68613da8be4907460089c6f1fa22 (diff)
downloadjgit-afef866a44cd65fef292c174cad445b3fb526400.tar.gz
jgit-afef866a44cd65fef292c174cad445b3fb526400.tar.xz
jgit-afef866a44cd65fef292c174cad445b3fb526400.zip
Move throw of PackInvalidException outside the catch
When a packfile is invalid, throw an exception explicitly outside any catch scope, so that is not accidentally caught by the generic catch-all cause, which would set the packfile as valid again. Flagging an invalid packfile as valid again would have dangerous consequences such as the corruption of the in-memory packlist. Bug: 544199 Change-Id: If7a3188a68d7985776b509d636d5ddf432bec798 Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java5
1 files changed, 3 insertions, 2 deletions
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 2ca9e83f1c..cbf7452131 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
@@ -643,9 +643,10 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
}
private void doOpen() throws IOException {
+ if (invalid) {
+ throw new PackInvalidException(packFile);
+ }
try {
- if (invalid)
- throw new PackInvalidException(packFile);
synchronized (readLock) {
fd = new RandomAccessFile(packFile, "r"); //$NON-NLS-1$
length = fd.length();

Back to the top