]> source.dussan.org Git - sonarqube.git/commitdiff
Fix concurrency probs in tests
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 10 Feb 2017 16:42:11 +0000 (17:42 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 10 Feb 2017 16:44:04 +0000 (17:44 +0100)
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/LogOutputRecorder.java

index 4021e964d109fb22385721d6e04ab6883c8279ba..5f980c04ade6dd248dbb47ef7595dae09326c1e3 100644 (file)
@@ -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();
   }