]> source.dussan.org Git - jgit.git/commitdiff
FsckError.CorruptObject: Use @Nullable constructor for errorType 56/130656/4
authorIvan Frade <ifrade@google.com>
Mon, 8 Oct 2018 21:43:17 +0000 (14:43 -0700)
committerIvan Frade <ifrade@google.com>
Tue, 9 Oct 2018 18:53:06 +0000 (11:53 -0700)
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>
org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java

index 131b0048ae664bfe61be04aa8cc2d2936136b506..5658c0a0e60882c4542cbc67b186601fbfa7946b 100644 (file)
@@ -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;
                }
 
index 5397ba47989b812d01fac1f662542bb002ce0bf7..50594df1dd7ff5903b4f75f8bb8e22ac8e8fda2f 100644 (file)
@@ -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()));
                }
        }