Skip to content

Commit 6cfb790

Browse files
committed
[JENKINS-8365] avoid unbounded memory consumption with a massive change.
1 parent 46a2670 commit 6cfb790

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/main/java/hudson/plugins/git/GitChangeLogParser.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public GitChangeSetList parse(AbstractBuild build, File changelogFile)
4949
lines = new ArrayList<String>();
5050
}
5151

52-
if (lines != null)
53-
lines.add(line);
52+
if (lines != null && lines.size()<THRESHOLD)
53+
lines.add(line); // TODO: if we ignored some lines, tell the user so.
5454
}
5555

5656
if (lines != null) {
@@ -67,5 +67,9 @@ public GitChangeSetList parse(AbstractBuild build, File changelogFile)
6767
private GitChangeSet parseCommit(List<String> lines, boolean authorOrCommitter) {
6868
return new GitChangeSet(lines, authorOrCommitter);
6969
}
70-
70+
71+
/**
72+
* To control the memory overhead of a large change, we ignore beyond certain number of lines.
73+
*/
74+
private static int THRESHOLD = 1000;
7175
}

0 commit comments

Comments
 (0)