Skip to content

Commit

Permalink
Fix NPE in DiffFormatter#getDiffDriver
Browse files Browse the repository at this point in the history
Guard against diff attribute with a null value.

Change-Id: Icc4b8d2f360ef105c6d64716cb42f2979967075b
  • Loading branch information
msohn committed Dec 5, 2024
1 parent 44d61a3 commit f2741ca
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1356,13 +1356,17 @@ private boolean matchesAny(List<Pattern> patterns, String text) {

private DiffDriver getDiffDriver(DiffEntry entry) {
Attribute diffAttr = entry.getDiffAttribute();
if (diffAttr != null) {
try {
return DiffDriver.valueOf(diffAttr.getValue());
} catch (IllegalArgumentException e) {
return null;
}
if (diffAttr == null) {
return null;
}
String diffAttrValue = diffAttr.getValue();
if (diffAttrValue == null) {
return null;
}
try {
return DiffDriver.valueOf(diffAttrValue);
} catch (IllegalArgumentException e) {
return null;
}
return null;
}
}

0 comments on commit f2741ca

Please sign in to comment.