Browse Source

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>
stable-5.2
Ivan Frade 6 years ago
parent
commit
7aebb6779c
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java
  2. 8
      org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java

10
org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckError.java

@ -61,20 +61,20 @@ public class FsckError {
final int type; final int type;
ObjectChecker.ErrorType errorType; final @Nullable ObjectChecker.ErrorType errorType;
/** /**
* @param id * @param id
* the object identifier. * the object identifier.
* @param type * @param type
* type of the object. * 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.id = id;
this.type = type; this.type = type;
}
void setErrorType(ObjectChecker.ErrorType errorType) {
this.errorType = errorType; this.errorType = errorType;
} }

8
org.eclipse.jgit/src/org/eclipse/jgit/internal/fsck/FsckPackParser.java

@ -174,12 +174,8 @@ public class FsckPackParser extends PackParser {
try { try {
super.verifySafeObject(id, type, data); super.verifySafeObject(id, type, data);
} catch (CorruptObjectException e) { } catch (CorruptObjectException e) {
// catch the exception and continue parse the pack file corruptObjects.add(
CorruptObject o = new CorruptObject(id.toObjectId(), type); new CorruptObject(id.toObjectId(), type, e.getErrorType()));
if (e.getErrorType() != null) {
o.setErrorType(e.getErrorType());
}
corruptObjects.add(o);
} }
} }

Loading…
Cancel
Save