From 7aebb6779c19d0c62a1c11fa89d19a1e5a03ea1c Mon Sep 17 00:00:00 2001 From: Ivan Frade Date: Mon, 8 Oct 2018 14:43:17 -0700 Subject: [PATCH] FsckError.CorruptObject: Use @Nullable constructor for errorType errorType is already null in the caller and callee when unknown, so we can replace a conditional call to a setter in the only caller with an unconditionally provided @Nullable constructor parameter. As a bonus, this lets us mark the field as final. Change-Id: Ie2f929180e74ffa1aba8ec6caccfa81fbd8bfc04 Signed-off-by: Ivan Frade --- .../src/org/eclipse/jgit/internal/fsck/FsckError.java | 10 +++++----- .../org/eclipse/jgit/internal/fsck/FsckPackParser.java | 8 ++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java index 131b0048a..5658c0a0e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java @@ -61,20 +61,20 @@ public class FsckError { final int type; - ObjectChecker.ErrorType errorType; + final @Nullable ObjectChecker.ErrorType errorType; /** * @param id * the object identifier. * @param type * type of the object. + * @param errorType + * kind of error */ - public CorruptObject(ObjectId id, int type) { + public CorruptObject(ObjectId id, int type, + @Nullable ObjectChecker.ErrorType errorType) { this.id = id; this.type = type; - } - - void setErrorType(ObjectChecker.ErrorType errorType) { this.errorType = errorType; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java index 5397ba479..50594df1d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java @@ -174,12 +174,8 @@ public class FsckPackParser extends PackParser { try { super.verifySafeObject(id, type, data); } catch (CorruptObjectException e) { - // catch the exception and continue parse the pack file - CorruptObject o = new CorruptObject(id.toObjectId(), type); - if (e.getErrorType() != null) { - o.setErrorType(e.getErrorType()); - } - corruptObjects.add(o); + corruptObjects.add( + new CorruptObject(id.toObjectId(), type, e.getErrorType())); } }