From 8f24ad80368cc005c78eb9fc83e4f23823048e16 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Tue, 31 May 2016 17:22:59 +0200 Subject: [PATCH] SONAR-7681 Use public implementation of List in MyBatis --- .../org/sonar/server/ce/ws/ActivityActionTest.java | 1 - .../src/main/java/org/sonar/db/ce/CeTaskQuery.java | 14 ++++++++------ .../org/sonar/db/component/ComponentTreeQuery.java | 7 +++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java index 5e05f81cf69..246d6018109 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java @@ -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)); diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeTaskQuery.java b/sonar-db/src/main/java/org/sonar/db/ce/CeTaskQuery.java index 17862ce6996..69b67d76ec9 100644 --- a/sonar-db/src/main/java/org/sonar/db/ce/CeTaskQuery.java +++ b/sonar-db/src/main/java/org/sonar/db/ce/CeTaskQuery.java @@ -19,12 +19,13 @@ */ 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 componentUuids; - private List statuses; + // SONAR-7681 a public implementation of List must be used in MyBatis - potential concurrency exceptions otherwise + private ArrayList componentUuids; + private ArrayList statuses; private String type; private Long minSubmittedAt; private Long maxExecutedAt; @@ -46,7 +48,7 @@ public class CeTaskQuery { } public CeTaskQuery setComponentUuids(@Nullable List 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 statuses) { - this.statuses = statuses; + this.statuses = statuses == null ? null : newArrayList(statuses); return this; } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java index 9b556abf99b..d7f1dee8746 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java @@ -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 qualifiers; + private final ArrayList 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; -- 2.39.5