Don't leak Repository and RevWalk instances during notedb parsing
Change-Id: Ia8d99f0387206295678234a549dc22a062e5655b
This commit is contained in:
@@ -68,7 +68,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Parser {
|
||||
private static class Parser implements AutoCloseable {
|
||||
private final Change.Id changeId;
|
||||
private final ObjectId tip;
|
||||
private final RevWalk walk;
|
||||
@@ -92,6 +92,11 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
draftPsComments = ArrayListMultimap.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
repo.close();
|
||||
}
|
||||
|
||||
private void parseDraftComments() throws IOException, ConfigInvalidException {
|
||||
walk.markStart(walk.parseCommit(tip));
|
||||
noteMap = CommentsInNotesUtil.parseCommentsFromNotes(repo,
|
||||
@@ -167,13 +172,16 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
||||
}
|
||||
|
||||
RevWalk walk = new RevWalk(reader);
|
||||
Parser parser = new Parser(getChangeId(), walk, rev, repoManager,
|
||||
draftsProject, author);
|
||||
parser.parseDraftComments();
|
||||
try (Parser parser = new Parser(getChangeId(), walk, rev, repoManager,
|
||||
draftsProject, author)) {
|
||||
parser.parseDraftComments();
|
||||
|
||||
buildCommentTable(draftBaseComments, parser.draftBaseComments);
|
||||
buildCommentTable(draftPsComments, parser.draftPsComments);
|
||||
noteMap = parser.noteMap;
|
||||
buildCommentTable(draftBaseComments, parser.draftBaseComments);
|
||||
buildCommentTable(draftPsComments, parser.draftPsComments);
|
||||
noteMap = parser.noteMap;
|
||||
} finally {
|
||||
walk.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user