summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler <Michael.Keppler@gmx.de>2019-03-09 12:37:10 +0100
committerDavid Pursehouse <david.pursehouse@gmail.com>2019-03-09 19:54:29 -0500
commit391c7a25fa8d247f9f6087f9f19ee330540ad602 (patch)
tree652633eeb6cda7ff357d5f6b6dce2d64f61d2907
parent0295ee1164bcd3b1741bd2a5142d2e40a49ca77a (diff)
downloadjgit-391c7a25fa8d247f9f6087f9f19ee330540ad602.tar.gz
jgit-391c7a25fa8d247f9f6087f9f19ee330540ad602.zip
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>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectId.java6
1 files changed, 5 insertions, 1 deletions
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 764f890158..0e96138c00 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.ObjectInputStream;
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 class ObjectId extends AnyObjectId implements Serializable {
* 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 {