]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7681 Use public implementation of List in MyBatis 1014/head
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 31 May 2016 15:22:59 +0000 (17:22 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 31 May 2016 15:57:41 +0000 (17:57 +0200)
server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java
sonar-db/src/main/java/org/sonar/db/ce/CeTaskQuery.java
sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java

index 5e05f81cf69d2a3ac0762597c09ce12c629b1f14..246d60181092d22673c7de762fadb1c08b51cae6 100644 (file)
@@ -149,7 +149,6 @@ public class ActivityActionTest {
     globalAdmin();
     insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
     String today = formatDate(new Date(EXECUTED_AT));
-    System.out.println(EXECUTED_AT + " - " + today);
 
     ActivityResponse activityResponse = call(ws.newRequest()
       .setParam(CeWsParameters.PARAM_MAX_EXECUTED_AT, today));
index 17862ce6996a2019c11ca8f2d372e0335c2ad741..69b67d76ec9fb8973e39d550951c9386661c4a35 100644 (file)
  */
 package org.sonar.db.ce;
 
+import java.util.ArrayList;
 import java.util.List;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.db.DatabaseUtils;
 
-import static java.util.Collections.singletonList;
+import static com.google.common.collect.Lists.newArrayList;
 
 /**
  * Db Query used for CE_QUEUE and CE_ACTIVITY tables
@@ -34,8 +35,9 @@ public class CeTaskQuery {
   public static final int MAX_COMPONENT_UUIDS = DatabaseUtils.PARTITION_SIZE_FOR_ORACLE;
 
   private boolean onlyCurrents = false;
-  private List<String> componentUuids;
-  private List<String> statuses;
+  // SONAR-7681 a public implementation of List must be used in MyBatis - potential concurrency exceptions otherwise
+  private ArrayList<String> componentUuids;
+  private ArrayList<String> statuses;
   private String type;
   private Long minSubmittedAt;
   private Long maxExecutedAt;
@@ -46,7 +48,7 @@ public class CeTaskQuery {
   }
 
   public CeTaskQuery setComponentUuids(@Nullable List<String> l) {
-    this.componentUuids = l;
+    this.componentUuids = l == null ? null : newArrayList(l);
     return this;
   }
 
@@ -58,7 +60,7 @@ public class CeTaskQuery {
     if (s == null) {
       this.componentUuids = null;
     } else {
-      this.componentUuids = singletonList(s);
+      this.componentUuids = newArrayList(s);
     }
     return this;
   }
@@ -78,7 +80,7 @@ public class CeTaskQuery {
   }
 
   public CeTaskQuery setStatuses(@Nullable List<String> statuses) {
-    this.statuses = statuses;
+    this.statuses = statuses == null ? null : newArrayList(statuses);
     return this;
   }
 
index 9b556abf99bd2500e3eee2da85c44f6ba253a742..d7f1dee8746ae926fd2785bb0aceee5488521c6d 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.db.component;
 
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
@@ -31,6 +32,7 @@ import org.sonar.db.WildcardPosition;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.collect.FluentIterable.from;
+import static com.google.common.collect.Lists.newArrayList;
 import static java.util.Objects.requireNonNull;
 import static org.sonar.db.DatabaseUtils.buildLikeValue;
 import static org.sonar.db.WildcardPosition.AFTER;
@@ -38,8 +40,9 @@ import static org.sonar.db.WildcardPosition.AFTER;
 public class ComponentTreeQuery {
   @CheckForNull
   private final String nameOrKeyQuery;
+  // SONAR-7681 a public implementation of List must be used in MyBatis - potential concurrency exceptions otherwise
   @CheckForNull
-  private final Collection<String> qualifiers;
+  private final ArrayList<String> qualifiers;
   @CheckForNull
   private final Integer page;
   @CheckForNull
@@ -51,7 +54,7 @@ public class ComponentTreeQuery {
 
   private ComponentTreeQuery(Builder builder) {
     this.nameOrKeyQuery = builder.nameOrKeyQuery;
-    this.qualifiers = builder.qualifiers;
+    this.qualifiers = builder.qualifiers == null ? null : newArrayList(builder.qualifiers);
     this.page = builder.page;
     this.pageSize = builder.pageSize;
     this.baseSnapshot = builder.baseSnapshot;