forked from phoedos/pmd
[core] Fix memory usage regression in CPD (#5090)
Merge pull request #5090 from Monits:issue-5066
This commit is contained in:
@ -40,6 +40,7 @@ See also [Maven PMD Plugin]({{ baseurl }}pmd_userdocs_tools_maven.html).
|
||||
* [#2827](https://github.com/pmd/pmd/issues/2827): \[cli] Consider processing errors in exit status
|
||||
* core
|
||||
* [#4992](https://github.com/pmd/pmd/pull/4992): \[core] CPD: Include processing errors in XML report
|
||||
* [#5066](https://github.com/pmd/pmd/issues/5066): \[core] CPD throws java.lang.OutOfMemoryError: Java heap space (since 7.1.0)
|
||||
* apex
|
||||
* [#4922](https://github.com/pmd/pmd/issues/4922): \[apex] SOQL syntax error with TYPEOF in sub-query
|
||||
* [#5053](https://github.com/pmd/pmd/issues/5053): \[apex] CPD fails to parse string literals with escaped characters
|
||||
|
@ -68,7 +68,7 @@ class MatchCollector {
|
||||
* - BC
|
||||
* It should be reduced to a single match with 3 marks
|
||||
*/
|
||||
if (tokenMatchSets.computeIfAbsent(mark1.getIndex(), HashSet::new).contains(mark2.getIndex())) {
|
||||
if (tokenMatchSets.computeIfAbsent(mark1.getIndex(), (i) -> new HashSet<>()).contains(mark2.getIndex())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ class MatchCollector {
|
||||
// always rely on the lowest mark index, as that's the order in which process them
|
||||
final int lowestKey = tokenMatchSets.get(mark1.getIndex()).stream().reduce(mark1.getIndex(), Math::min);
|
||||
|
||||
List<Match> matches = matchTree.computeIfAbsent(lowestKey, ArrayList::new);
|
||||
List<Match> matches = matchTree.computeIfAbsent(lowestKey, (i) -> new ArrayList<>());
|
||||
Iterator<Match> matchIterator = matches.iterator();
|
||||
while (matchIterator.hasNext()) {
|
||||
Match m = matchIterator.next();
|
||||
@ -116,8 +116,8 @@ class MatchCollector {
|
||||
}
|
||||
|
||||
private void registerTokenMatch(TokenEntry mark1, TokenEntry mark2) {
|
||||
tokenMatchSets.computeIfAbsent(mark1.getIndex(), HashSet::new).add(mark2.getIndex());
|
||||
tokenMatchSets.computeIfAbsent(mark2.getIndex(), HashSet::new).add(mark1.getIndex());
|
||||
tokenMatchSets.computeIfAbsent(mark1.getIndex(), (i) -> new HashSet<>()).add(mark2.getIndex());
|
||||
tokenMatchSets.computeIfAbsent(mark2.getIndex(), (i) -> new HashSet<>()).add(mark1.getIndex());
|
||||
}
|
||||
|
||||
List<Match> getMatches() {
|
||||
|
Reference in New Issue
Block a user