commit | 5f66017496ea70899bec8cca464c5a2e04865988 | [log] [tgz] |
---|---|---|
author | Patrizio <patrizio.gelosi@amarulasolutions.com> | Fri Oct 18 12:28:32 2024 +0200 |
committer | Patrizio <patrizio.gelosi@amarulasolutions.com> | Fri Oct 18 17:26:27 2024 +0200 |
tree | 77a4992ac43d80ba1ce2f5a642ae1ebe4f4f0f33 | |
parent | 02fe7c4cf96e1971a2fa9a32cbda68f63ab44cbb [diff] |
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 {