From 6df32e0c9a825537b21aa28d5bf1cdfebf1eae6d Mon Sep 17 00:00:00 2001
From: Michael Keppler <Michael.Keppler@gmx.de>
Date: Sat, 9 Mar 2019 12:37:10 +0100
Subject: [PATCH 4/5] Avoid NPE in ObjectId.isId()
That method can easily be invoked with a null argument (e.g.
isId(repo.getFullBranch()), therefore it should handle null arguments.
Change was suggested in https://git.eclipse.org/r/#/c/137918/, which
tried to fix the same in egit only.
Bug:544982
Change-Id: I32d1df6e9b2946ab324eda7008721159019316b3
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
---
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java
index 764f890..0e96138 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java
@@ -49,6 +49,7 @@
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.errors.InvalidObjectIdException;
import org.eclipse.jgit.util.NB;
import org.eclipse.jgit.util.RawParseUtils;
@@ -86,7 +87,10 @@ public static final ObjectId zeroId() {
* the string to test.
* @return true if the string can converted into an ObjectId.
*/
- public static final boolean isId(String id) {
+ public static final boolean isId(@Nullable String id) {
+ if (id == null) {
+ return false;
+ }
if (id.length() != Constants.OBJECT_ID_STRING_LENGTH)
return false;
try {
--
2.20.1