From 517323fbd5fca8fe12e48656f827007bdc0e260e Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 21 Aug 2017 14:02:08 -0700 Subject: [PATCH] JCLOUDS-1225: Address Guava 18 MoreExecutors changes Fixed with: find -name \*.java | xargs sed -i 's/sameThreadExecutor/newDirectExecutorService/g' --- .../java/org/jclouds/ec2/internal/BaseEC2ApiMockTest.java | 4 ++-- .../compute/ElasticStackComputeServiceAdapterTest.java | 2 +- .../org/jclouds/oauth/v2/AuthorizationApiMockTest.java | 4 ++-- .../openstack/v2_0/internal/BaseOpenStackMockTest.java | 4 ++-- .../org/jclouds/openstack/swift/v1/TempAuthMockTest.java | 4 ++-- .../s3/src/test/java/org/jclouds/s3/S3ClientMockTest.java | 4 ++-- .../blobstore/functions/BucketsToStorageMetadataTest.java | 4 ++-- .../org/jclouds/sqs/features/PermissionApiLiveTest.java | 4 ++-- .../java/org/jclouds/blobstore/options/PutOptions.java | 2 +- ...ckUntilInitScriptStatusIsZeroThenReturnOutputTest.java | 8 ++++---- ...NodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java | 4 ++-- core/src/main/java/org/jclouds/ContextBuilder.java | 4 ++-- .../org/jclouds/lifecycle/config/LifeCycleModule.java | 4 ++-- .../java/org/jclouds/concurrent/FutureIterablesTest.java | 6 +++--- .../org/jclouds/rest/internal/BaseRestApiExpectTest.java | 4 ++-- .../java/org/jclouds/rest/internal/BaseRestApiTest.java | 4 ++-- .../gae/config/GoogleAppEngineConfigurationModule.java | 4 ++-- .../jclouds/aws/ec2/internal/BaseAWSEC2ApiMockTest.java | 4 ++-- .../test/java/org/jclouds/b2/features/B2TestUtils.java | 2 +- .../internal/BaseDigitalOcean2ApiMockTest.java | 4 ++-- .../java/org/jclouds/dynect/v3/DynectApiMockTest.java | 4 ++-- .../internal/BaseGoogleCloudStorageApiMockTest.java | 4 ++-- .../internal/BaseGoogleComputeEngineApiMockTest.java | 4 ++-- .../packet/compute/internal/BasePacketApiMockTest.java | 4 ++-- 24 files changed, 48 insertions(+), 48 deletions(-) diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiMockTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiMockTest.java index 900d2177f3..c89a9f3c3f 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiMockTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiMockTest.java @@ -18,7 +18,7 @@ package org.jclouds.ec2.internal; import static com.google.common.base.Throwables.propagate; import static com.google.common.net.HttpHeaders.CONTENT_TYPE; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.MediaType.APPLICATION_XML; import static org.jclouds.util.Strings2.toStringAndClose; import static org.testng.Assert.assertEquals; @@ -71,7 +71,7 @@ public class BaseEC2ApiMockTest { .modules(modules); } - private final Set modules = ImmutableSet.of(new ExecutorServiceModule(sameThreadExecutor())); + private final Set modules = ImmutableSet.of(new ExecutorServiceModule(newDirectExecutorService())); @BeforeMethod public void start() throws IOException { diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapterTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapterTest.java index 70ce180bf4..d922acaba5 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapterTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapterTest.java @@ -102,7 +102,7 @@ public class ElasticStackComputeServiceAdapterTest { replay(api); ElasticStackComputeServiceAdapter adapter = new ElasticStackComputeServiceAdapter(api, driveNotClaimed, - preInstalledImageSupplier, driveCache, "12345678", MoreExecutors.sameThreadExecutor()); + preInstalledImageSupplier, driveCache, "12345678", MoreExecutors.newDirectExecutorService()); try { adapter.createNodeWithGroupEncodedIntoName("mock-group", "mock-name", template); diff --git a/apis/oauth/src/test/java/org/jclouds/oauth/v2/AuthorizationApiMockTest.java b/apis/oauth/src/test/java/org/jclouds/oauth/v2/AuthorizationApiMockTest.java index 89fe953e2b..792f8bb4c9 100644 --- a/apis/oauth/src/test/java/org/jclouds/oauth/v2/AuthorizationApiMockTest.java +++ b/apis/oauth/src/test/java/org/jclouds/oauth/v2/AuthorizationApiMockTest.java @@ -18,7 +18,7 @@ package org.jclouds.oauth.v2; import static com.google.common.base.Charsets.UTF_8; import static com.google.common.io.BaseEncoding.base64Url; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; import static org.jclouds.oauth.v2.config.CredentialType.P12_PRIVATE_KEY_CREDENTIALS; @@ -235,7 +235,7 @@ public class AuthorizationApiMockTest { .credentials("foo", toStringAndClose(OAuthTestUtils.class.getResourceAsStream("/testpk.pem"))) .endpoint(url.toString()) .overrides(overrides) - .modules(ImmutableSet.of(new ExecutorServiceModule(sameThreadExecutor()), new OAuthModule(), new Module() { + .modules(ImmutableSet.of(new ExecutorServiceModule(newDirectExecutorService()), new OAuthModule(), new Module() { @Override public void configure(Binder binder) { binder.bind(OAuthScopes.class).toInstance(SingleScope.create(SCOPE)); } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java index a7cc79dc39..a67a038193 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.v2_0.internal; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -58,7 +58,7 @@ public class BaseOpenStackMockTest { public static final String accessRackspace = "{\"access\":{\"token\":{\"id\":\"b84f4a37-5126-4603-9521-ccd0665fbde1\",\"expires\":\"2013-04-13T16:49:57.000-05:00\",\"tenant\":{\"id\":\"123123\",\"name\":\"123123\"}},\"serviceCatalog\":[{\"endpoints\":[{\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\"}],\"name\":\"cloudMonitoring\",\"type\":\"rax:monitor\"},{\"endpoints\":[{\"region\":\"DFW\",\"tenantId\":\"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\",\"publicURL\":\"URL/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\"},{\"region\":\"ORD\",\"tenantId\":\"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\",\"publicURL\":\"URL/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\"}],\"name\":\"cloudFilesCDN\",\"type\":\"rax:object-cdn\"},{\"endpoints\":[{\"region\":\"ORD\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\"},{\"region\":\"DFW\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\"}],\"name\":\"cloudLoadBalancers\",\"type\":\"rax:load-balancer\"},{\"endpoints\":[{\"region\":\"DFW\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\"},{\"region\":\"ORD\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\"}],\"name\":\"cloudDatabases\",\"type\":\"rax:database\"},{\"endpoints\":[{\"region\":\"DFW\",\"tenantId\":\"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\",\"publicURL\":\"URL/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\",\"internalURL\":\"URL/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\"},{\"region\":\"ORD\",\"tenantId\":\"MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\",\"publicURL\":\"URL/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\",\"internalURL\":\"URL/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9\"}],\"name\":\"cloudFiles\",\"type\":\"object-store\"},{\"endpoints\":[{\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\",\"versionInfo\":\"URL/v1.0\",\"versionList\":\"URL/\",\"versionId\":\"1.0\"}],\"name\":\"cloudServers\",\"type\":\"compute\"},{\"endpoints\":[{\"region\":\"DFW\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v2/123123\",\"versionInfo\":\"URL/v2\",\"versionList\":\"URL/\",\"versionId\":\"2\"},{\"region\":\"ORD\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v2/123123\",\"versionInfo\":\"URL/v2\",\"versionList\":\"URL/\",\"versionId\":\"2\"}],\"name\":\"cloudServersOpenStack\",\"type\":\"compute\"},{\"endpoints\":[{\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\"}],\"name\":\"cloudDNS\",\"type\":\"rax:dns\"},{\"endpoints\":[{\"tenantId\":\"123123\",\"publicURL\":\"URL/v1.0/123123\"}],\"name\":\"cloudBackup\",\"type\":\"rax:backup\"},{\"endpoints\":[{\"region\":\"DFW\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1/123123\"},{\"region\":\"ORD\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1/123123\"}],\"name\":\"cloudBlockStorage\",\"type\":\"volume\"},{\"endpoints\":[{\"region\":\"DFW\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1/123123\",\"internalURL\":\"URL/v1/123123\"},{\"region\":\"ORD\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1/123123\",\"internalURL\":\"URL/v1/123123\"}],\"name\":\"zaqar\",\"type\":\"messaging\"},{\"endpoints\":[{\"region\":\"DFW\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1/123123\",\"internalURL\":\"URL/v1/123123\"},{\"region\":\"ORD\",\"tenantId\":\"123123\",\"publicURL\":\"URL/v1/123123\",\"internalURL\":\"URL/v1/123123\"}],\"name\":\"autoscale\",\"type\":\"rax:autoscale\"}],\"user\":{\"id\":\"1234\",\"roles\":[{\"id\":\"3\",\"description\":\"User Admin Role.\",\"name\":\"identity:user-admin\"}],\"name\":\"jclouds-joe\",\"RAX-AUTH:defaultRegion\":\"DFW\"}}}"; private final Set modules = ImmutableSet. of( - new ExecutorServiceModule(sameThreadExecutor())); + new ExecutorServiceModule(newDirectExecutorService())); /** * Pattern for replacing the URL token with the correct local address. diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java index dd440d91e8..685a232214 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/TempAuthMockTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.swift.v1; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.assertj.core.api.Assertions.assertThat; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; @@ -93,7 +93,7 @@ public class TempAuthMockTest { .credentials("user", "password") .endpoint(authUrl) .overrides(overrides) - .modules(ImmutableSet.of(new ExecutorServiceModule(sameThreadExecutor()))) + .modules(ImmutableSet.of(new ExecutorServiceModule(newDirectExecutorService()))) .buildApi(SwiftApi.class); } diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ClientMockTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ClientMockTest.java index cf31df3228..8374253398 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ClientMockTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ClientMockTest.java @@ -19,7 +19,7 @@ package org.jclouds.s3; import static com.google.common.net.HttpHeaders.CONTENT_LENGTH; import static com.google.common.net.HttpHeaders.ETAG; import static com.google.common.net.HttpHeaders.EXPECT; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.assertj.core.api.Assertions.assertThat; import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; import static org.testng.Assert.assertEquals; @@ -46,7 +46,7 @@ import com.squareup.okhttp.mockwebserver.RecordedRequest; public class S3ClientMockTest { private static final Set modules = ImmutableSet. of(new OkHttpCommandExecutorServiceModule(), - new ExecutorServiceModule(sameThreadExecutor())); + new ExecutorServiceModule(newDirectExecutorService())); static S3Client getS3Client(URL server) { Properties overrides = new Properties(); diff --git a/apis/s3/src/test/java/org/jclouds/s3/blobstore/functions/BucketsToStorageMetadataTest.java b/apis/s3/src/test/java/org/jclouds/s3/blobstore/functions/BucketsToStorageMetadataTest.java index 3d638db6cc..46fa6b5a22 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/blobstore/functions/BucketsToStorageMetadataTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/blobstore/functions/BucketsToStorageMetadataTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.s3.blobstore.functions; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.testng.Assert.assertEquals; import org.jclouds.blobstore.domain.MutableStorageMetadata; @@ -49,7 +49,7 @@ public class BucketsToStorageMetadataTest { public void test() { BucketsToStorageMetadata fn = new BucketsToStorageMetadata( - sameThreadExecutor(), + newDirectExecutorService(), new BucketToResourceMetadata(Functions.forMap(ImmutableMap. of("mycontainer", region)))); MutableStorageMetadata expected = new MutableStorageMetadataImpl(); diff --git a/apis/sqs/src/test/java/org/jclouds/sqs/features/PermissionApiLiveTest.java b/apis/sqs/src/test/java/org/jclouds/sqs/features/PermissionApiLiveTest.java index 7a04b9b4d5..b8a7f31cda 100644 --- a/apis/sqs/src/test/java/org/jclouds/sqs/features/PermissionApiLiveTest.java +++ b/apis/sqs/src/test/java/org/jclouds/sqs/features/PermissionApiLiveTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.sqs.features; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.jclouds.providers.AnonymousProviderMetadata.forApiOnEndpoint; import static org.jclouds.sqs.reference.SQSParameters.ACTION; import static org.testng.Assert.assertEquals; @@ -91,7 +91,7 @@ public class PermissionApiLiveTest extends BaseSQSApiLiveTest { private AnonymousAttributesApi getAnonymousAttributesApi(URI queue) { return ContextBuilder.newBuilder(forApiOnEndpoint(AnonymousAttributesApi.class, queue.toASCIIString())) - .modules(ImmutableSet. of(new ExecutorServiceModule(sameThreadExecutor()))) + .modules(ImmutableSet. of(new ExecutorServiceModule(newDirectExecutorService()))) .buildApi(AnonymousAttributesApi.class); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/options/PutOptions.java b/blobstore/src/main/java/org/jclouds/blobstore/options/PutOptions.java index d80ab860ba..983355c4ae 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/options/PutOptions.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/options/PutOptions.java @@ -43,7 +43,7 @@ public class PutOptions implements Cloneable { private boolean useCustomExecutor = false; // TODO: This exposes ListeningExecutorService to the user, instead of a regular ExecutorService - private ListeningExecutorService customExecutor = MoreExecutors.sameThreadExecutor(); + private ListeningExecutorService customExecutor = MoreExecutors.newDirectExecutorService(); public PutOptions() { } diff --git a/compute/src/test/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutputTest.java b/compute/src/test/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutputTest.java index 7d71e4ce63..fe3803d701 100644 --- a/compute/src/test/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutputTest.java +++ b/compute/src/test/java/org/jclouds/compute/callables/BlockUntilInitScriptStatusIsZeroThenReturnOutputTest.java @@ -132,7 +132,7 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutputTest { EventBus eventBus = new EventBus(); public void testExitStatusZeroReturnsExecResponse() throws InterruptedException, ExecutionException { - ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor(); + ListeningExecutorService userExecutor = MoreExecutors.newDirectExecutorService(); Predicate notRunningAnymore = Predicates.alwaysTrue(); SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod("runAction") .addMockedMethod("getStatement").addMockedMethod("getNode").addMockedMethod("toString") @@ -160,7 +160,7 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutputTest { public void testFirstExitStatusOneButSecondExitStatusZeroReturnsExecResponse() throws InterruptedException, ExecutionException { - ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor(); + ListeningExecutorService userExecutor = MoreExecutors.newDirectExecutorService(); Predicate notRunningAnymore = Predicates.alwaysTrue(); SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod("runAction") @@ -194,7 +194,7 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutputTest { } public void testCancelInterruptStopsCommand() throws InterruptedException, ExecutionException { - ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor(); + ListeningExecutorService userExecutor = MoreExecutors.newDirectExecutorService(); Predicate notRunningAnymore = Predicates.alwaysTrue(); SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod( "refreshAndRunAction").addMockedMethod("runAction").addMockedMethod("getStatement").addMockedMethod( @@ -239,7 +239,7 @@ public class BlockUntilInitScriptStatusIsZeroThenReturnOutputTest { public void testCancelDontInterruptLeavesCommandRunningAndReturnsLastStatus() throws InterruptedException, ExecutionException { - ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor(); + ListeningExecutorService userExecutor = MoreExecutors.newDirectExecutorService(); Predicate notRunningAnymore = Predicates.alwaysTrue(); SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod("runAction") .addMockedMethod("getStatement").addMockedMethod("getNode").addMockedMethod("toString") diff --git a/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java b/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java index 5b57db4b65..bd3a299658 100644 --- a/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java +++ b/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.compute.callables; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static com.google.inject.name.Names.named; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; @@ -51,7 +51,7 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; @Test(groups = "unit", singleThreaded = true, testName = "RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest") public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest { - Injector injector = Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()), + Injector injector = Guice.createInjector(new ExecutorServiceModule(newDirectExecutorService()), new AbstractModule() { protected void configure() { bindConstant().annotatedWith(named(PROPERTY_USER_THREADS)).to(1); diff --git a/core/src/main/java/org/jclouds/ContextBuilder.java b/core/src/main/java/org/jclouds/ContextBuilder.java index a547599332..7c6cbc5991 100644 --- a/core/src/main/java/org/jclouds/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/ContextBuilder.java @@ -31,7 +31,7 @@ import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Lists.newArrayListWithCapacity; import static com.google.common.collect.Maps.filterKeys; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.jclouds.Constants.PROPERTY_API; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; @@ -547,7 +547,7 @@ public class ContextBuilder { return input.getClass().isAnnotationPresent(SingleThreaded.class); } })) { - modules.add(new ExecutorServiceModule(sameThreadExecutor())); + modules.add(new ExecutorServiceModule(newDirectExecutorService())); } else { modules.add(new ExecutorServiceModule()); } diff --git a/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java b/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java index f002217ebc..e978c248d6 100644 --- a/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java +++ b/core/src/main/java/org/jclouds/lifecycle/config/LifeCycleModule.java @@ -18,7 +18,7 @@ package org.jclouds.lifecycle.config; import static com.google.common.base.Throwables.propagate; import static com.google.common.collect.Iterables.filter; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static com.google.inject.matcher.Matchers.any; import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; import static org.jclouds.Constants.PROPERTY_USER_THREADS; @@ -117,7 +117,7 @@ public class LifeCycleModule extends AbstractModule { invokeOnInjectee(method, injectee); } - }, sameThreadExecutor()); + }, newDirectExecutorService()); } }); } diff --git a/core/src/test/java/org/jclouds/concurrent/FutureIterablesTest.java b/core/src/test/java/org/jclouds/concurrent/FutureIterablesTest.java index 4e815f114d..b40584a674 100644 --- a/core/src/test/java/org/jclouds/concurrent/FutureIterablesTest.java +++ b/core/src/test/java/org/jclouds/concurrent/FutureIterablesTest.java @@ -18,7 +18,7 @@ package org.jclouds.concurrent; import static com.google.common.collect.Maps.newHashMap; import static com.google.common.util.concurrent.Futures.immediateFailedFuture; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.jclouds.concurrent.FutureIterables.transformParallel; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -53,7 +53,7 @@ public class FutureIterablesTest { counter.incrementAndGet(); return immediateFailedFuture(new AuthorizationException()); } - }, sameThreadExecutor(), null, Logger.NULL, ""); + }, newDirectExecutorService(), null, Logger.NULL, ""); fail("Expected AuthorizationException"); } catch (AuthorizationException e) { assertEquals(counter.get(), 2); @@ -70,7 +70,7 @@ public class FutureIterablesTest { counter.incrementAndGet(); return immediateFailedFuture(new RuntimeException()); } - }, sameThreadExecutor(), null, Logger.CONSOLE, ""); + }, newDirectExecutorService(), null, Logger.CONSOLE, ""); fail("Expected TransformParallelException"); } catch (TransformParallelException e) { assertEquals(e.getFromToException().size(), 2); diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java index d0f1aa4eff..c6c66b36f6 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiExpectTest.java @@ -17,7 +17,7 @@ package org.jclouds.rest.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static com.google.inject.name.Names.named; import static org.jclouds.Constants.PROPERTY_IDEMPOTENT_METHODS; import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; @@ -226,7 +226,7 @@ public abstract class BaseRestApiExpectTest { @Override public void configure() { - bind(ListeningExecutorService.class).annotatedWith(named(PROPERTY_USER_THREADS)).toInstance(sameThreadExecutor()); + bind(ListeningExecutorService.class).annotatedWith(named(PROPERTY_USER_THREADS)).toInstance(newDirectExecutorService()); bind(new TypeLiteral>() { }).toInstance(fn); bind(HttpCommandExecutorService.class).to(ExpectHttpCommandExecutorService.class); diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java index b3b9b3a0a2..915aa9911c 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java @@ -18,7 +18,7 @@ package org.jclouds.rest.internal; import static com.google.common.base.Throwables.propagate; import static com.google.common.hash.Hashing.md5; import static com.google.common.net.HttpHeaders.TRANSFER_ENCODING; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static com.google.inject.name.Names.named; import static org.easymock.EasyMock.createMock; import static org.jclouds.Constants.PROPERTY_USER_THREADS; @@ -77,7 +77,7 @@ public abstract class BaseRestApiTest { @Override protected void configure() { - bind(ListeningExecutorService.class).annotatedWith(named(PROPERTY_USER_THREADS)).toInstance(sameThreadExecutor()); + bind(ListeningExecutorService.class).annotatedWith(named(PROPERTY_USER_THREADS)).toInstance(newDirectExecutorService()); bind(HttpCommandExecutorService.class).toInstance(mock); } diff --git a/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java b/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java index 30faccef7b..fb6fd66fcb 100644 --- a/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java +++ b/drivers/gae/src/main/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModule.java @@ -16,7 +16,7 @@ */ package org.jclouds.gae.config; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import org.jclouds.concurrent.SingleThreaded; import org.jclouds.concurrent.config.ConfiguresExecutorService; @@ -46,7 +46,7 @@ public class GoogleAppEngineConfigurationModule extends AbstractModule { private final Module userExecutorModule; public GoogleAppEngineConfigurationModule() { - this(new ExecutorServiceModule(sameThreadExecutor())); + this(new ExecutorServiceModule(newDirectExecutorService())); } /** diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/internal/BaseAWSEC2ApiMockTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/internal/BaseAWSEC2ApiMockTest.java index 7ad46c88ac..aae84d9f15 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/internal/BaseAWSEC2ApiMockTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/internal/BaseAWSEC2ApiMockTest.java @@ -19,7 +19,7 @@ package org.jclouds.aws.ec2.internal; import static com.google.common.base.Throwables.propagate; import static com.google.common.net.HttpHeaders.AUTHORIZATION; import static com.google.common.net.HttpHeaders.CONTENT_TYPE; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.MediaType.APPLICATION_XML; import static org.assertj.core.api.Assertions.assertThat; import static org.jclouds.util.Strings2.toStringAndClose; @@ -90,7 +90,7 @@ public class BaseAWSEC2ApiMockTest { } private final Set modules = ImmutableSet - .of(new MockAWSEC2HttpApiModule(), new ExecutorServiceModule(sameThreadExecutor())); + .of(new MockAWSEC2HttpApiModule(), new ExecutorServiceModule(newDirectExecutorService())); @ConfiguresHttpApi class MockAWSEC2HttpApiModule extends AWSEC2HttpApiModule { diff --git a/providers/b2/src/test/java/org/jclouds/b2/features/B2TestUtils.java b/providers/b2/src/test/java/org/jclouds/b2/features/B2TestUtils.java index 8d3e3a0928..20be6f276a 100644 --- a/providers/b2/src/test/java/org/jclouds/b2/features/B2TestUtils.java +++ b/providers/b2/src/test/java/org/jclouds/b2/features/B2TestUtils.java @@ -41,7 +41,7 @@ import com.squareup.okhttp.mockwebserver.RecordedRequest; final class B2TestUtils { static B2Api api(String uri, String provider, Properties overrides) { Set modules = ImmutableSet. of( - new ExecutorServiceModule(MoreExecutors.sameThreadExecutor())); + new ExecutorServiceModule(MoreExecutors.newDirectExecutorService())); return ContextBuilder.newBuilder(provider) .credentials("ACCOUNT_ID", "APPLICATION_KEY") diff --git a/providers/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java b/providers/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java index ca0c4bd7e8..16f92c6975 100644 --- a/providers/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java +++ b/providers/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java @@ -18,7 +18,7 @@ package org.jclouds.digitalocean2.internal; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Iterables.getOnlyElement; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -51,7 +51,7 @@ public class BaseDigitalOcean2ApiMockTest { private static final String MOCK_BEARER_TOKEN = "c5401990f0c24135e8d6b5d260603fc71696d4738da9aa04a720229a01a2521d"; private static final String DEFAULT_ENDPOINT = new DigitalOcean2ProviderMetadata().getEndpoint(); - private final Set modules = ImmutableSet. of(new ExecutorServiceModule(sameThreadExecutor())); + private final Set modules = ImmutableSet. of(new ExecutorServiceModule(newDirectExecutorService())); protected MockWebServer server; protected DigitalOcean2Api api; diff --git a/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java b/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java index 969371e3f1..c5bd5b379e 100644 --- a/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java +++ b/providers/dynect/src/test/java/org/jclouds/dynect/v3/DynectApiMockTest.java @@ -16,7 +16,7 @@ */ package org.jclouds.dynect.v3; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.Response.Status.OK; import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; @@ -39,7 +39,7 @@ import com.squareup.okhttp.mockwebserver.MockWebServer; public class DynectApiMockTest { private static final Set modules = ImmutableSet. of( - new ExecutorServiceModule(sameThreadExecutor())); + new ExecutorServiceModule(newDirectExecutorService())); static DynECTApi mockDynectApi(String uri) { Properties overrides = new Properties(); diff --git a/providers/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiMockTest.java b/providers/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiMockTest.java index c30314530a..80db201220 100644 --- a/providers/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiMockTest.java +++ b/providers/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiMockTest.java @@ -18,7 +18,7 @@ package org.jclouds.googlecloudstorage.internal; import static com.google.common.base.Charsets.UTF_8; import static com.google.common.base.Throwables.propagate; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.jclouds.googlecloud.config.GoogleCloudProperties.CREDENTIAL_TYPE; import static org.jclouds.googlecloud.config.GoogleCloudProperties.PROJECT_NAME; @@ -74,7 +74,7 @@ public class BaseGoogleCloudStorageApiMockTest { } private final Set modules = ImmutableSet - .of(new ExecutorServiceModule(sameThreadExecutor()), new OkHttpCommandExecutorServiceModule()); + .of(new ExecutorServiceModule(newDirectExecutorService()), new OkHttpCommandExecutorServiceModule()); final AtomicInteger suffix = new AtomicInteger(); diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java index 23ed532cbb..d45a6ea18d 100644 --- a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java +++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java @@ -18,7 +18,7 @@ package org.jclouds.googlecomputeengine.internal; import static com.google.common.base.Charsets.UTF_8; import static com.google.common.base.Throwables.propagate; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; import static org.jclouds.googlecloud.config.GoogleCloudProperties.CREDENTIAL_TYPE; @@ -83,7 +83,7 @@ public class BaseGoogleComputeEngineApiMockTest { } private final Set modules = ImmutableSet - .of(new ExecutorServiceModule(sameThreadExecutor()), GoogleComputeEngineTestModule.INSTANCE, new OkHttpCommandExecutorServiceModule()); + .of(new ExecutorServiceModule(newDirectExecutorService()), GoogleComputeEngineTestModule.INSTANCE, new OkHttpCommandExecutorServiceModule()); final AtomicInteger suffix = new AtomicInteger(); diff --git a/providers/packet/src/test/java/org/jclouds/packet/compute/internal/BasePacketApiMockTest.java b/providers/packet/src/test/java/org/jclouds/packet/compute/internal/BasePacketApiMockTest.java index 9fe3d6fb51..18aaf5fb85 100644 --- a/providers/packet/src/test/java/org/jclouds/packet/compute/internal/BasePacketApiMockTest.java +++ b/providers/packet/src/test/java/org/jclouds/packet/compute/internal/BasePacketApiMockTest.java @@ -43,7 +43,7 @@ import com.squareup.okhttp.mockwebserver.RecordedRequest; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Iterables.getOnlyElement; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; import static org.testng.Assert.assertEquals; @@ -52,7 +52,7 @@ public class BasePacketApiMockTest { private static final String X_AUTHORIZATION_TOKEN = "c5401990f0c24135e8d6b5d260603fc71696d4738da9aa04a720229a01a2521d"; private static final String DEFAULT_ENDPOINT = new PacketProviderMetadata().getEndpoint(); - private final Set modules = ImmutableSet. of(new ExecutorServiceModule(sameThreadExecutor())); + private final Set modules = ImmutableSet. of(new ExecutorServiceModule(newDirectExecutorService())); protected MockWebServer server; protected PacketApi api;