diff options
author | Ivan Frade <ifrade@google.com> | 2018-10-08 14:43:17 -0700 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2018-10-09 11:53:06 -0700 |
commit | 7aebb6779c19d0c62a1c11fa89d19a1e5a03ea1c (patch) | |
tree | d93b9caba1a9099acbabc711b21db41ed883bbfb | |
parent | 9372791fcf0e3350a457cf5cf0959ccd3fff95fe (diff) | |
download | jgit-7aebb6779c19d0c62a1c11fa89d19a1e5a03ea1c.tar.gz jgit-7aebb6779c19d0c62a1c11fa89d19a1e5a03ea1c.zip |
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 <ifrade@google.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java | 10 | ||||
-rw-r--r-- | org.eclipse.jgit/src/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 131b0048ae..5658c0a0e6 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 5397ba4798..50594df1dd 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())); } } |