Skip to content

Commit a040554

Browse files
committed
BUG : a new reviewInput is reinstanciated for every sub-module in multi-module analysis.
Corrected by creating a ReviewHolder singleton. Change-Id: Ie1624bbb73d556a3c198363c54ac7f50212fb79c
1 parent 8ad3374 commit a040554

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>fr.techad</groupId>
77
<artifactId>sonar-gerrit-plugin</artifactId>
88
<packaging>sonar-plugin</packaging>
9-
<version>2.0.0</version>
9+
<version>2.0.1</version>
1010

1111
<name>Sonar Gerrit Plugin</name>
1212
<description>Sonar will rate your gerrit patch set and comment on found alerts.</description>

src/main/java/fr/techad/sonar/GerritDecorator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class GerritDecorator implements Decorator, PostJob {
4949
private GerritFacade gerritFacade;
5050
// Sonar's long name to Gerrit original file name map.
5151
private Map<String, String> gerritModifiedFiles;
52-
private ReviewInput reviewInput = new ReviewInput();
52+
private ReviewInput reviewInput = ReviewHolder.getReviewInput();
5353
private final ResourcePerspectives perspectives;
5454

5555
public GerritDecorator(Settings settings, ResourcePerspectives perspectives) {
@@ -236,8 +236,12 @@ protected void processFileResource(@NotNull Resource resource, @NotNull Decorato
236236
commentIssues(issuable, comments);
237237
commentAlerts(context, comments);
238238
if (!comments.isEmpty()) {
239+
LOG.debug("[GERRIT PLUGIN] comments not empty. Adding to reviewInput. {}", comments);
239240
reviewInput.addComments(gerritModifiedFiles.get(resource.getLongName()), comments);
240241
}
242+
else {
243+
LOG.debug("[GERRIT PLUGIN] comments empty. Nothing to add");
244+
}
241245
}
242246

243247
protected String substituteProperties(String originalMessage) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package fr.techad.sonar;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
import fr.techad.sonar.gerrit.ReviewInput;
7+
8+
public class ReviewHolder {
9+
private static final Logger LOG = LoggerFactory.getLogger(ReviewHolder.class);
10+
private static ReviewInput reviewInput = new ReviewInput();
11+
12+
private ReviewHolder() {
13+
}
14+
15+
public static ReviewInput getReviewInput() {
16+
LOG.debug("[GERRIT PLUGIN] Returning ReviewHolder.reviewInput");
17+
return reviewInput;
18+
}
19+
}

0 commit comments

Comments
 (0)