From 489cf6df2a0deed4d8f65a25fb2131605fa4785c Mon Sep 17 00:00:00 2001 From: SkyBlaise Date: Tue, 5 Sep 2023 13:54:51 +0800 Subject: [PATCH] fix null pointer exception caused by getDeletedLineWithHighestSimilarityInDiff returning null --- .../reposense/authorship/analyzer/AuthorshipAnalyzer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/reposense/authorship/analyzer/AuthorshipAnalyzer.java b/src/main/java/reposense/authorship/analyzer/AuthorshipAnalyzer.java index 0df2731268..5284ef95ba 100644 --- a/src/main/java/reposense/authorship/analyzer/AuthorshipAnalyzer.java +++ b/src/main/java/reposense/authorship/analyzer/AuthorshipAnalyzer.java @@ -114,6 +114,10 @@ private static CandidateLine getDeletedLineWithHighestSimilarity(RepoConfigurati CandidateLine candidateLine = getDeletedLineWithHighestSimilarityInDiff( fileDiffResult, lineContent, parentCommit, preImageFilePath); + if (candidateLine == null) { + continue; + } + if (highestSimilarityLine == null || candidateLine.getSimilarityScore() > highestSimilarityLine.getSimilarityScore()) { highestSimilarityLine = candidateLine;