Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-11498] ConcurrentModificationException when recording …
…scores for matrix build
  • Loading branch information
kutzi committed Apr 9, 2012
1 parent e09bbdb commit e12f121
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/hudson/plugins/cigame/model/ScoreCard.java
Expand Up @@ -35,28 +35,34 @@ public class ScoreCard {
* @param listener
*/
public void record(AbstractBuild<?, ?> build, RuleSet ruleset, BuildListener listener) {
if (scores == null) {
scores = new LinkedList<Score>();
}

List<Score> scoresForBuild = new LinkedList<Score>();
for (Rule rule : ruleset.getRules()) {
if (listener != null) {
listener.getLogger().append("[ci-game] evaluating rule: " + rule.getName() + "\n");
}
RuleResult<?> result = evaluate(build, rule);
if ((result != null) && (result.getPoints() != 0)) {
Score score = new Score(ruleset.getName(), rule.getName(), result.getPoints(), result.getDescription());
scores.add(score);
scoresForBuild.add(score);

if (listener != null) {
listener.getLogger().append("[ci-game] scored: " + score.getValue() + "\n");
}
}
}
Collections.sort(scores);

// prevent ConcurrentModificationExceptions for e.g. matrix builds (see JENKINS-11498):
synchronized(this) {
if (scores == null) {
scores = new LinkedList<Score>();
}
scores.addAll(scoresForBuild);
Collections.sort(scores);
}
}

@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
RuleResult<?> evaluate(AbstractBuild<?, ?> build, Rule rule) {
if (rule instanceof AggregatableRule<?> && build instanceof MavenModuleSetBuild) {
AggregatableRule aRule = (AggregatableRule<?>)rule;
Expand Down

0 comments on commit e12f121

Please sign in to comment.