Browse Source

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>
stable-4.5
Luca Milanesio 6 years ago committed by Matthias Sohn
parent
commit
afef866a44
  1. 5
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

5
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 { private void doOpen() throws IOException {
try { if (invalid) {
if (invalid)
throw new PackInvalidException(packFile); throw new PackInvalidException(packFile);
}
try {
synchronized (readLock) { synchronized (readLock) {
fd = new RandomAccessFile(packFile, "r"); //$NON-NLS-1$ fd = new RandomAccessFile(packFile, "r"); //$NON-NLS-1$
length = fd.length(); length = fd.length();

Loading…
Cancel
Save