ObjectReader: Allow getCommitGraph to throw IOException
ObjectReader#getCommitGraph doesn't report errors loading the commit graph. The caller should be aware of the situation and ultimately decide what to do. Add IOException to ObjectReader#getCommitGraph signature. RevWalk defaults to an empty commit-graph on IO errors. Signed-off-by: Xing Huang <xingkhuang@google.com> Change-Id: I38eeacff76c7f926b6dfb192d1e5916e40770024
This commit is contained in:
parent
e8042d02e6
commit
eccae7cf0b
|
@ -512,9 +512,12 @@ public ObjectReachabilityChecker createObjectReachabilityChecker(
|
||||||
* (default is
|
* (default is
|
||||||
* {@value org.eclipse.jgit.lib.CoreConfig#DEFAULT_COMMIT_GRAPH_ENABLE}).
|
* {@value org.eclipse.jgit.lib.CoreConfig#DEFAULT_COMMIT_GRAPH_ENABLE}).
|
||||||
*
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* if it cannot open any of the underlying commit graph.
|
||||||
|
*
|
||||||
* @since 6.5
|
* @since 6.5
|
||||||
*/
|
*/
|
||||||
public Optional<CommitGraph> getCommitGraph() {
|
public Optional<CommitGraph> getCommitGraph() throws IOException {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,7 +664,7 @@ public BitmapIndex getBitmapIndex() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<CommitGraph> getCommitGraph() {
|
public Optional<CommitGraph> getCommitGraph() throws IOException{
|
||||||
return delegate().getCommitGraph();
|
return delegate().getCommitGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1173,8 +1173,13 @@ byte[] getCachedBytes(RevObject obj, ObjectLoader ldr)
|
||||||
@NonNull
|
@NonNull
|
||||||
CommitGraph commitGraph() {
|
CommitGraph commitGraph() {
|
||||||
if (commitGraph == null) {
|
if (commitGraph == null) {
|
||||||
commitGraph = reader != null ? reader.getCommitGraph().orElse(EMPTY)
|
try {
|
||||||
|
commitGraph = reader != null
|
||||||
|
? reader.getCommitGraph().orElse(EMPTY)
|
||||||
: EMPTY;
|
: EMPTY;
|
||||||
|
} catch (IOException e) {
|
||||||
|
commitGraph = EMPTY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return commitGraph;
|
return commitGraph;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue