Fix crashes when scanning Git projects Addressed a NullPointerException that could occur in infrequent cases when retrieving the file tree in a Git project. This exception is now properly handled. Change-Id: I7cc35d3951c3ddc369bd12322213bb40e57cfcda Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/git/GitRepoFiles.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/git/GitRepoFiles.java index 25b8b6b..a8bd8a8 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/git/GitRepoFiles.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/stateful/client/api/git/GitRepoFiles.java
@@ -127,6 +127,10 @@ try (RevWalk revWalk = new RevWalk(repository)) { return revWalk.parseCommit(lastCommitId).getTree(); } + catch (NullPointerException e) { + log.warn("Error retrieving Master Rev Tree for ID `{}`", lastCommitId, e); + throw new IOException(e); + } } private String readFileContent(ObjectReader reader, RevTree tree, String path) throws IOException {