summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2021-02-11 13:31:09 +0100
committerGitHub <noreply@github.com>2021-02-11 13:31:09 +0100
commit74d80502ec269488f6058cb8c00eb4bae84e8a25 (patch)
tree1b0ec9aa426d5f992047ce8b0e1d5a8e5ce51b05 /configserver
parentcc328616254d131072156a8a632e9cf1215527b2 (diff)
parentc290816a4444d16fab5023373178654ea2fe67d6 (diff)
Merge pull request #16477 from vespa-engine/hmusum/avoid-possible-concurrent-modification
Use an unmodifiable collection to avoid possible concurrent modification
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java13
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java1
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java15
3 files changed, 11 insertions, 18 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index a72381d4e84..81ea8d76f14 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -73,9 +73,7 @@ import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.stats.LockStats;
import com.yahoo.vespa.curator.stats.ThreadLockStats;
import com.yahoo.vespa.defaults.Defaults;
-import com.yahoo.vespa.flags.BooleanFlag;
import com.yahoo.vespa.flags.FlagSource;
-import com.yahoo.vespa.flags.Flags;
import com.yahoo.vespa.flags.InMemoryFlagSource;
import com.yahoo.vespa.orchestrator.Orchestrator;
@@ -90,6 +88,7 @@ import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -150,8 +149,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
ConfigserverConfig configserverConfig,
Orchestrator orchestrator,
TesterClient testerClient,
- Metric metric,
- FlagSource flagSource) {
+ Metric metric) {
this(tenantRepository,
hostProvisionerProvider.getHostProvisioner(),
infraDeployerProvider.getInfraDeployer(),
@@ -163,7 +161,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
Clock.systemUTC(),
testerClient,
metric,
- flagSource,
new DefaultClusterReindexingStatusClient());
}
@@ -178,7 +175,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
Clock clock,
TesterClient testerClient,
Metric metric,
- FlagSource flagSource,
ClusterReindexingStatusClient clusterReindexingStatusClient) {
this.tenantRepository = Objects.requireNonNull(tenantRepository);
this.hostProvisioner = Objects.requireNonNull(hostProvisioner);
@@ -275,7 +271,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
clock,
testerClient,
metric,
- flagSource,
ClusterReindexingStatusClient.DUMMY_INSTANCE);
}
@@ -835,7 +830,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public void deleteExpiredLocalSessions() {
Map<Tenant, Collection<LocalSession>> sessionsPerTenant = new HashMap<>();
- tenantRepository.getAllTenants().forEach(tenant -> sessionsPerTenant.put(tenant, tenant.getSessionRepository().getLocalSessions()));
+ tenantRepository.getAllTenants()
+ .forEach(tenant -> sessionsPerTenant.put(tenant,
+ List.copyOf(tenant.getSessionRepository().getLocalSessions())));
Set<ApplicationId> applicationIds = new HashSet<>();
sessionsPerTenant.values()
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index dae79486775..6318572ce5f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -141,7 +141,6 @@ public class ApplicationRepositoryTest {
.withProvisioner(provisioner)
.withConfigserverConfig(configserverConfig)
.withOrchestrator(orchestrator)
- .withFlagSource(flagSource)
.withLogRetriever(new MockLogRetriever())
.withClock(clock)
.build();
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
index d747df7cb41..a1d436a7c0b 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
@@ -28,8 +28,6 @@ import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
import com.yahoo.vespa.config.util.ConfigUtils;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
-import com.yahoo.vespa.flags.FlagSource;
-import com.yahoo.vespa.flags.InMemoryFlagSource;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.VespaModelFactory;
import org.junit.Rule;
@@ -73,10 +71,10 @@ public class SessionRepositoryTest {
public TemporaryFolder temporaryFolder = new TemporaryFolder();
public void setup() throws Exception {
- setup(new InMemoryFlagSource(), new ModelFactoryRegistry(List.of(new VespaModelFactory(new NullConfigModelRegistry()))));
+ setup(new ModelFactoryRegistry(List.of(new VespaModelFactory(new NullConfigModelRegistry()))));
}
- private void setup(FlagSource flagSource, ModelFactoryRegistry modelFactoryRegistry) throws Exception {
+ private void setup(ModelFactoryRegistry modelFactoryRegistry) throws Exception {
curator = new MockCurator();
File configserverDbDir = temporaryFolder.newFolder().getAbsoluteFile();
ConfigserverConfig configserverConfig = new ConfigserverConfig.Builder()
@@ -96,7 +94,6 @@ public class SessionRepositoryTest {
.withTenantRepository(tenantRepository)
.withProvisioner(new MockProvisioner())
.withOrchestrator(new OrchestratorMock())
- .withFlagSource(flagSource)
.build();
sessionRepository = tenantRepository.getTenant(tenantName).getSessionRepository();
}
@@ -191,7 +188,7 @@ public class SessionRepositoryTest {
okFactory.vespaVersion = new Version(1, 1, 0);
okFactory.throwOnLoad = false;
- setup(new InMemoryFlagSource(), new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
+ setup(new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
deploy();
}
@@ -207,7 +204,7 @@ public class SessionRepositoryTest {
okFactory.vespaVersion = new Version(2, 0, 0);
okFactory.throwOnLoad = false;
- setup(new InMemoryFlagSource(), new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
+ setup(new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
deploy();
}
@@ -222,7 +219,7 @@ public class SessionRepositoryTest {
okFactory.vespaVersion = new Version(2, 0, 0);
okFactory.throwErrorOnLoad = false;
- setup(new InMemoryFlagSource(), new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
+ setup(new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
File testApp = new File("src/test/apps/app-major-version-2");
deploy(applicationId, testApp);
@@ -240,7 +237,7 @@ public class SessionRepositoryTest {
okFactory.vespaVersion = new Version(1, 0, 0);
okFactory.throwErrorOnLoad = false;
- setup(new InMemoryFlagSource(), new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
+ setup(new ModelFactoryRegistry(List.of(okFactory, failingFactory)));
File testApp = new File("src/test/apps/app-major-version-2");
deploy(applicationId, testApp);