diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2015-01-21 22:27:46 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-01-21 22:27:46 +0100 |
commit | e7f153bf3a28139a40faf5dde5270da0ce50aa4b (patch) | |
tree | 4e1b535bf931164a22084f6512b28beb8a00d4a7 /org.eclipse.jgit/src/org | |
parent | e09e7c064e93684aa1ce8f67186e0613bc432d18 (diff) | |
parent | 58f3ecea9b7779b349964fa12fb1d47cbd77540d (diff) | |
download | jgit-e7f153bf3a28139a40faf5dde5270da0ce50aa4b.tar.gz jgit-e7f153bf3a28139a40faf5dde5270da0ce50aa4b.zip |
Merge remote-tracking branch 'origin/stable-3.6'
* origin/stable-3.6:
Prepare 3.6.3-SNAPSHOT builds
JGit v3.6.2.201501210735-r
Don't remove pack from pack list for problems which could be transient
Log reason for ignoring pack when IOException occurred
Change-Id: I61141b52839511d58e5a5b193bfde31e9f444a6c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java | 2 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java | 40 |
2 files changed, 32 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index 65272fb0bd..fd38dc1491 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -190,6 +190,7 @@ public class JGitText extends TranslationBundle { /***/ public String corruptObjectNotree; /***/ public String corruptObjectNoType; /***/ public String corruptObjectPackfileChecksumIncorrect; + /***/ public String corruptPack; /***/ public String couldNotCheckOutBecauseOfConflicts; /***/ public String couldNotDeleteLockFileShouldNotHappen; /***/ public String couldNotDeleteTemporaryIndexFileShouldNotHappen; @@ -266,6 +267,7 @@ public class JGitText extends TranslationBundle { /***/ public String exceptionCaughtDuringExecutionOfTagCommand; /***/ public String exceptionOccurredDuringAddingOfOptionToALogCommand; /***/ public String exceptionOccurredDuringReadingOfGIT_DIR; + /***/ public String exceptionWhileReadingPack; /***/ public String expectedACKNAKFoundEOF; /***/ public String expectedACKNAKGot; /***/ public String expectedBooleanStringValue; 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 58276051ea..76fadefe53 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 @@ -52,6 +52,8 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; @@ -64,6 +66,8 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jgit.errors.CorruptObjectException; +import org.eclipse.jgit.errors.PackInvalidException; import org.eclipse.jgit.errors.PackMismatchException; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.storage.pack.ObjectToPack; @@ -328,9 +332,7 @@ public class ObjectDirectory extends FileObjectDatabase { try { p.resolve(matches, id, RESOLVE_ABBREV_LIMIT); } catch (IOException e) { - // Assume the pack is corrupted. - // - removePack(p); + handlePackError(e, p); } if (matches.size() > RESOLVE_ABBREV_LIMIT) return; @@ -417,8 +419,7 @@ public class ObjectDirectory extends FileObjectDatabase { if (searchPacksAgain(pList)) continue SEARCH; } catch (IOException e) { - // Assume the pack is corrupted. - removePack(p); + handlePackError(e, p); } } break SEARCH; @@ -498,8 +499,7 @@ public class ObjectDirectory extends FileObjectDatabase { if (searchPacksAgain(pList)) continue SEARCH; } catch (IOException e) { - // Assume the pack is corrupted. - removePack(p); + handlePackError(e, p); } } break SEARCH; @@ -540,9 +540,7 @@ public class ObjectDirectory extends FileObjectDatabase { pList = scanPacks(pList); continue SEARCH; } catch (IOException e) { - // Assume the pack is corrupted. - // - removePack(p); + handlePackError(e, p); } } break SEARCH; @@ -552,6 +550,28 @@ public class ObjectDirectory extends FileObjectDatabase { h.db.selectObjectRepresentation(packer, otp, curs); } + private void handlePackError(IOException e, PackFile p) { + String tmpl; + if ((e instanceof CorruptObjectException) + || (e instanceof PackInvalidException)) { + tmpl = JGitText.get().corruptPack; + // Assume the pack is corrupted, and remove it from the list. + removePack(p); + } else { + tmpl = JGitText.get().exceptionWhileReadingPack; + // Don't remove the pack from the list, as the error may be + // transient. + } + StringBuilder buf = new StringBuilder(MessageFormat.format(tmpl, + p.getPackFile().getAbsolutePath())); + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + buf.append('\n'); + buf.append(sw.toString()); + // TODO instead of syserr we should use a logging framework + System.err.println(buf.toString()); + } + @Override InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId id, boolean createDuplicate) throws IOException { |