Skip to content

Commit 5db57fe

Browse files
committed
BlameRegionMerger: report invalid regions with checked exception.
If the cached regions are invalid the merger throws an IllegalStateException. This is too strict. The caller can just continue working as if there was no cache. Report the error as IOException, that the caller can catch and handle. Change-Id: I19a1061225533b46d3a17936912a11000430f2ce
1 parent 3483bd7 commit 5db57fe

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

org.eclipse.jgit.test/tst/org/eclipse/jgit/blame/BlameRegionMergerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void blame_exactOverlap() throws IOException {
174174
public void blame_corruptedIndex() {
175175
Region outOfRange = new Region(0, 43, 4);
176176
// This region is out of the blamed area
177-
assertThrows(IllegalStateException.class,
177+
assertThrows(IOException.class,
178178
() -> blamer.mergeOneRegion(outOfRange));
179179
}
180180

org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameRegionMerger.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Candidate mergeCandidate(Candidate candidate) {
7272
List<Candidate> mergeOneRegion(Region region) throws IOException {
7373
List<CacheRegion> overlaps = findOverlaps(region);
7474
if (overlaps.isEmpty()) {
75-
throw new IllegalStateException(
75+
throw new IOException(
7676
"Cached blame should cover all lines");
7777
}
7878
/*

0 commit comments

Comments
 (0)