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>
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;
}
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()));
}
}