diff options
author | jackdt@google.com <jackdt@google.com> | 2024-12-03 16:21:55 -0800 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2024-12-05 00:00:32 +0000 |
commit | bd57a19fa35b6de493926e2996b28235b96b5690 (patch) | |
tree | 6080fdcccbd219843cf30fc58781b17fcf68c3a7 | |
parent | a960da9866ea86a6909911d7249a1bbfe1b628ac (diff) | |
download | jgit-bd57a19fa35b6de493926e2996b28235b96b5690.tar.gz jgit-bd57a19fa35b6de493926e2996b28235b96b5690.zip |
TreeWalk: Make a null check before dereferencing the config variable.
Gerrit finds a null pointer exception accessing the conf in some merge operations. It is not clear why, but could be related to [1] and [2] where the attributes node provider is set (instead of being null).
Check if the config is there before reading the value and return null if not (as if the config didn't have the value set). The config is @Nullable so this check makes sense in any case.
[1] https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1203278
[2] https://gerrit-review.git.corp.google.com/c/gerrit/+/441721
Change-Id: I2b786c0a23fa2e09fb9fe041c025d42823defb04
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java index aaac2a72e0..f66b3f65de 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java @@ -38,12 +38,12 @@ import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.CoreConfig.EolStreamType; import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.MutableObjectId; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectReader; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.CoreConfig.EolStreamType; import org.eclipse.jgit.revwalk.RevTree; import org.eclipse.jgit.treewalk.filter.PathFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; @@ -1591,6 +1591,9 @@ public class TreeWalk implements AutoCloseable, AttributesProvider { String filterCommand = filterCommandsByNameDotType.get(key); if (filterCommand != null) return filterCommand; + if (config == null) { + return null; + } filterCommand = config.getString(ConfigConstants.CONFIG_FILTER_SECTION, filterDriverName, filterCommandType); boolean useBuiltin = config.getBoolean( |