diff options
author | Tom <tw201207@gmail.com> | 2016-11-23 18:30:48 +0100 |
---|---|---|
committer | Florian Zschocke <2362065+flaix@users.noreply.github.com> | 2021-11-03 20:37:06 +0100 |
commit | 9142f1f74d5ab60335eb9f7d38b946c75f109460 (patch) | |
tree | dbf3ab456a4c296ea54119f410958b789ea9d62c /src/main/java | |
parent | 560f2e3ab0f78429fe22dc23ae25de6a7500cf02 (diff) | |
download | gitblit-9142f1f74d5ab60335eb9f7d38b946c75f109460.tar.gz gitblit-9142f1f74d5ab60335eb9f7d38b946c75f109460.zip |
Fix NPE
Although it seems strange to have a RefModel with a referenced object
but a null Ref, Gitblit uses such RefModels for instance in
JGitUtils.getNotesOnCommit().
Be careful to do something sensible when that Ref is null.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/gitblit/models/RefModel.java | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/models/RefModel.java b/src/main/java/com/gitblit/models/RefModel.java index 86d98474..43517180 100644 --- a/src/main/java/com/gitblit/models/RefModel.java +++ b/src/main/java/com/gitblit/models/RefModel.java @@ -59,9 +59,9 @@ public class RefModel implements Serializable, Comparable<RefModel> { this.reference = ref;
this.displayName = displayName;
this.date = internalGetDate(refObject);
- this.name = (ref != null) ? ref.getName() : displayName;
+ this.name = ref != null ? ref.getName() : displayName;
this.type = internalGetReferencedObjectType(refObject);
- this.objectId = internalGetObjectId(reference);
+ this.objectId = ref != null ? ref.getObjectId() : ObjectId.zeroId();
this.id = this.objectId.getName();
this.referencedObjectId = internalGetReferencedObjectId(refObject);
this.referencedId = this.referencedObjectId.getName();
@@ -163,10 +163,6 @@ public class RefModel implements Serializable, Comparable<RefModel> { return person;
}
- private ObjectId internalGetObjectId(Ref reference) {
- return reference.getObjectId();
- }
-
public ObjectId getObjectId() {
if (objectId == null) {
objectId = ObjectId.fromString(id);
@@ -178,7 +174,7 @@ public class RefModel implements Serializable, Comparable<RefModel> { if (referencedObject instanceof RevTag) {
return !getReferencedObjectId().equals(getObjectId());
}
- return reference.getPeeledObjectId() != null;
+ return reference != null && reference.getPeeledObjectId() != null;
}
public boolean isAnnotatedTag() {
|