aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-02-10 17:42:11 +0100
committerDuarte Meneses <duarte.meneses@sonarsource.com>2017-02-10 17:44:04 +0100
commit4718aff422ab4617abdc2b70dd17a16247912c8b (patch)
tree5e08e78c275860b0a045b9c02b27cf191d3d7ecc
parentcfa372a57a3065302dc92c77f3ba2068c7ddf771 (diff)
downloadsonarqube-4718aff422ab4617abdc2b70dd17a16247912c8b.tar.gz
sonarqube-4718aff422ab4617abdc2b70dd17a16247912c8b.zip
Fix concurrency probs in tests
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/LogOutputRecorder.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/LogOutputRecorder.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/LogOutputRecorder.java
index 4021e964d10..5f980c04ade 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/LogOutputRecorder.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/LogOutputRecorder.java
@@ -19,6 +19,7 @@
*/
package org.sonar.scanner.mediumtest;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -40,19 +41,19 @@ public class LogOutputRecorder implements LogOutput {
asString.append(formattedMessage).append("\n");
}
- public Collection<String> getAll() {
- return recorded;
+ public synchronized Collection<String> getAll() {
+ return new ArrayList<>(recorded);
}
- public String getAllAsString() {
+ public synchronized String getAllAsString() {
return recorded.stream().collect(Collectors.joining("\n"));
}
- public Collection<String> get(String level) {
- return recordedByLevel.get(level);
+ public synchronized Collection<String> get(String level) {
+ return new ArrayList<>(recordedByLevel.get(level));
}
- public String getAsString() {
+ public synchronized String getAsString() {
return asString.toString();
}