diff --git a/.kokoro/build.sh b/.kokoro/build.sh
index 07007c9e5baa..c7f821ff8fbe 100755
--- a/.kokoro/build.sh
+++ b/.kokoro/build.sh
@@ -57,8 +57,7 @@ fi
mvn install -B -V \
-DskipTests=true \
-Dmaven.javadoc.skip=true \
- -Dgcloud.download.skip=true \
- -T 1C
+ -Dgcloud.download.skip=true
# if GOOGLE_APPLICATION_CREDIENTIALS is specified as a relative path prepend Kokoro root directory onto it
if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then
diff --git a/google-cloud-bom/pom.xml b/google-cloud-bom/pom.xml
index b2d9de89f991..bd9b60daec01 100644
--- a/google-cloud-bom/pom.xml
+++ b/google-cloud-bom/pom.xml
@@ -362,17 +362,17 @@
com.google.cloudgoogle-cloud-core
- 1.90.1-SNAPSHOT
+ 1.90.0com.google.cloudgoogle-cloud-core-grpc
- 1.90.1-SNAPSHOT
+ 1.90.0com.google.cloudgoogle-cloud-core-http
- 1.90.1-SNAPSHOT
+ 1.90.0com.google.cloud
diff --git a/google-cloud-clients/google-cloud-core-grpc/README.md b/google-cloud-clients/google-cloud-core-grpc/README.md
new file mode 100644
index 000000000000..eda7975d6a47
--- /dev/null
+++ b/google-cloud-clients/google-cloud-core-grpc/README.md
@@ -0,0 +1,3 @@
+# Google Cloud Java Client -- Core gRPC extensions
+
+This client has moved to https://github.com/googleapis/java-core
\ No newline at end of file
diff --git a/google-cloud-clients/google-cloud-core-grpc/pom.xml b/google-cloud-clients/google-cloud-core-grpc/pom.xml
deleted file mode 100644
index da06d875fbd4..000000000000
--- a/google-cloud-clients/google-cloud-core-grpc/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
- 4.0.0
- google-cloud-core-grpc
- 1.90.1-SNAPSHOT
- jar
- Google Cloud Core gRPC
- https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc
-
- Core gRPC module for the google-cloud.
-
-
- com.google.cloud
- google-cloud-clients
- 0.108.1-alpha-SNAPSHOT
-
-
- google-cloud-core-grpc
-
-
-
- com.google.auth
- google-auth-library-credentials
-
-
- com.google.cloud
- google-cloud-core
-
-
- com.google.guava
- guava
-
-
- junit
- junit
- test
-
-
- org.easymock
- easymock
- test
-
-
- org.objenesis
- objenesis
- test
-
-
- com.google.api
- gax-grpc
-
-
-
\ No newline at end of file
diff --git a/google-cloud-clients/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java b/google-cloud-clients/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java
deleted file mode 100644
index dffa4d37ee63..000000000000
--- a/google-cloud-clients/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.grpc;
-
-import com.google.api.client.http.HttpResponseException;
-import com.google.api.core.BetaApi;
-import com.google.api.core.InternalApi;
-import com.google.api.gax.rpc.ApiException;
-import com.google.cloud.BaseServiceException;
-import com.google.common.base.MoreObjects;
-import java.io.IOException;
-import java.util.Collections;
-
-/** Base class for all exceptions from grpc-based services. */
-public class BaseGrpcServiceException extends BaseServiceException {
-
- private static final long serialVersionUID = -2685197215731335549L;
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseGrpcServiceException(String message, Throwable cause, int code, boolean retryable) {
- super(
- ExceptionData.newBuilder()
- .setMessage(message)
- .setCause(cause)
- .setCode(code)
- .setRetryable(retryable)
- .build());
- }
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseGrpcServiceException(IOException exception, boolean idempotent) {
- super(makeExceptionData(exception, idempotent));
- }
-
- private static ExceptionData makeExceptionData(IOException exception, boolean idempotent) {
- int code = UNKNOWN_CODE;
- Boolean retryable = null;
- if (exception instanceof HttpResponseException) {
- // In cases where an exception is an instance of HttpResponseException,
- // check the status code to determine whether it's retryable
- code = ((HttpResponseException) exception).getStatusCode();
- retryable =
- BaseServiceException.isRetryable(code, null, idempotent, Collections.emptySet());
- }
- return ExceptionData.newBuilder()
- .setMessage(exception.getMessage())
- .setCause(exception)
- .setRetryable(
- MoreObjects.firstNonNull(
- retryable, BaseServiceException.isRetryable(idempotent, exception)))
- .setCode(code)
- .setReason(null)
- .setLocation(null)
- .setDebugInfo(null)
- .build();
- }
-
- @BetaApi
- public BaseGrpcServiceException(ApiException apiException) {
- super(
- ExceptionData.newBuilder()
- .setMessage(apiException.getMessage())
- .setCause(apiException)
- .setRetryable(apiException.isRetryable())
- .setCode(apiException.getStatusCode().getCode().getHttpStatusCode())
- .setReason(apiException.getStatusCode().getCode().name())
- .setLocation(null)
- .setDebugInfo(null)
- .build());
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java b/google-cloud-clients/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
deleted file mode 100644
index 841cc8218bc9..000000000000
--- a/google-cloud-clients/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright 2016 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.grpc;
-
-import static com.google.common.base.MoreObjects.firstNonNull;
-
-import com.google.api.core.BetaApi;
-import com.google.api.core.InternalApi;
-import com.google.api.gax.core.CredentialsProvider;
-import com.google.api.gax.core.FixedCredentialsProvider;
-import com.google.api.gax.core.NoCredentialsProvider;
-import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
-import com.google.api.gax.retrying.RetrySettings;
-import com.google.api.gax.rpc.TransportChannelProvider;
-import com.google.api.gax.rpc.UnaryCallSettings;
-import com.google.auth.Credentials;
-import com.google.cloud.NoCredentials;
-import com.google.cloud.ServiceOptions;
-import com.google.cloud.TransportOptions;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import io.grpc.internal.SharedResourceHolder;
-import io.grpc.internal.SharedResourceHolder.Resource;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Objects;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-/** Class representing service options for those services that use gRPC as the transport layer. */
-public class GrpcTransportOptions implements TransportOptions {
-
- private static final long serialVersionUID = -9049538465533951165L;
- private final String executorFactoryClassName;
-
- private transient ExecutorFactory executorFactory;
-
- /** Shared thread pool executor. */
- private static final Resource EXECUTOR =
- new Resource() {
- @Override
- public ScheduledExecutorService create() {
- ScheduledThreadPoolExecutor service =
- new ScheduledThreadPoolExecutor(
- 8,
- new ThreadFactoryBuilder()
- .setDaemon(true)
- .setNameFormat("grpc-transport-%d")
- .build());
- service.setKeepAliveTime(5, TimeUnit.SECONDS);
- service.allowCoreThreadTimeOut(true);
- service.setRemoveOnCancelPolicy(true);
- return service;
- }
-
- @Override
- public void close(ScheduledExecutorService instance) {
- instance.shutdown();
- }
- };
-
- /**
- * An interface for {@link ExecutorService} factories. Implementations of this interface can be
- * used to provide an user-defined executor to execute requests. Any implementation of this
- * interface must override the {@code get()} method to return the desired executor. The {@code
- * release(executor)} method should be overriden to free resources used by the executor (if
- * needed) according to application's logic.
- *
- *
Implementation must provide a public no-arg constructor. Loading of a factory implementation
- * is done via {@link java.util.ServiceLoader}.
- *
- * @param the {@link ExecutorService} subclass created by this factory
- */
- public interface ExecutorFactory {
-
- /** Gets an executor service instance. */
- T get();
-
- /** Releases resources used by the executor and possibly shuts it down. */
- void release(T executor);
- }
-
- @InternalApi
- public static class DefaultExecutorFactory implements ExecutorFactory {
-
- private static final DefaultExecutorFactory INSTANCE = new DefaultExecutorFactory();
-
- @Override
- public ScheduledExecutorService get() {
- return SharedResourceHolder.get(EXECUTOR);
- }
-
- @Override
- public synchronized void release(ScheduledExecutorService executor) {
- SharedResourceHolder.release(EXECUTOR, executor);
- }
- }
-
- /** Builder for {@code GrpcTransportOptions}. */
- public static class Builder {
-
- private ExecutorFactory executorFactory;
-
- private Builder() {}
-
- private Builder(GrpcTransportOptions options) {
- executorFactory = options.executorFactory;
- }
-
- public GrpcTransportOptions build() {
- return new GrpcTransportOptions(this);
- }
-
- /**
- * Sets the scheduled executor factory. This method can be used to provide an user-defined
- * scheduled executor to execute requests.
- *
- * @return the builder
- */
- public Builder setExecutorFactory(ExecutorFactory executorFactory) {
- this.executorFactory = executorFactory;
- return this;
- }
- }
-
- @SuppressWarnings("unchecked")
- private GrpcTransportOptions(Builder builder) {
- executorFactory =
- firstNonNull(
- builder.executorFactory,
- ServiceOptions.getFromServiceLoader(
- ExecutorFactory.class, DefaultExecutorFactory.INSTANCE));
- executorFactoryClassName = executorFactory.getClass().getName();
- }
-
- /** Returns a scheduled executor service provider. */
- public ExecutorFactory getExecutorFactory() {
- return executorFactory;
- }
-
- /** Returns a builder for API call settings. */
- @Deprecated
- public UnaryCallSettings.Builder getApiCallSettings(RetrySettings retrySettings) {
- return UnaryCallSettings.newUnaryCallSettingsBuilder().setRetrySettings(retrySettings);
- }
-
- /** Returns a channel provider from the given default provider. */
- @BetaApi
- public static TransportChannelProvider setUpChannelProvider(
- InstantiatingGrpcChannelProvider.Builder providerBuilder,
- ServiceOptions, ?> serviceOptions) {
- providerBuilder.setEndpoint(serviceOptions.getHost());
- return providerBuilder.build();
- }
-
- public static CredentialsProvider setUpCredentialsProvider(ServiceOptions, ?> serviceOptions) {
- Credentials scopedCredentials = serviceOptions.getScopedCredentials();
- if (scopedCredentials != null && scopedCredentials != NoCredentials.getInstance()) {
- return FixedCredentialsProvider.create(scopedCredentials);
- }
- return NoCredentialsProvider.create();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(executorFactoryClassName);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- GrpcTransportOptions other = (GrpcTransportOptions) obj;
- return Objects.equals(executorFactoryClassName, other.executorFactoryClassName);
- }
-
- private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException {
- input.defaultReadObject();
- executorFactory = ServiceOptions.newInstance(executorFactoryClassName);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java b/google-cloud-clients/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java
deleted file mode 100644
index 696de60c550c..000000000000
--- a/google-cloud-clients/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.grpc;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import com.google.api.gax.grpc.GrpcStatusCode;
-import com.google.api.gax.rpc.InternalException;
-import com.google.cloud.BaseServiceException;
-import com.google.cloud.RetryHelper;
-import io.grpc.Status.Code;
-import java.io.IOException;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import org.junit.Test;
-
-public class BaseGrpcServiceExceptionTest {
-
- private static final String MESSAGE = "some message";
- private static final boolean NOT_RETRYABLE = false;
- private static final boolean IDEMPOTENT = true;
-
- @Test
- public void testBaseServiceException() {
- BaseGrpcServiceException serviceException = null;
-
- IOException exception = new SocketTimeoutException();
- serviceException = new BaseGrpcServiceException(exception, IDEMPOTENT);
- assertTrue(serviceException.isRetryable());
- assertNull(serviceException.getMessage());
- assertEquals(exception, serviceException.getCause());
- assertNull(serviceException.getReason());
- assertNull(serviceException.getLocation());
- assertNull(serviceException.getDebugInfo());
-
- exception = new SocketException();
- serviceException = new BaseGrpcServiceException(exception, IDEMPOTENT);
- assertTrue(serviceException.isRetryable());
- assertNull(serviceException.getMessage());
- assertEquals(exception, serviceException.getCause());
- assertNull(serviceException.getReason());
- assertNull(serviceException.getLocation());
- assertNull(serviceException.getDebugInfo());
-
- exception = new IOException("insufficient data written");
- serviceException = new BaseGrpcServiceException(exception, IDEMPOTENT);
- assertTrue(serviceException.isRetryable());
- assertEquals("insufficient data written", serviceException.getMessage());
- assertEquals(exception, serviceException.getCause());
- assertNull(serviceException.getReason());
- assertNull(serviceException.getLocation());
- assertNull(serviceException.getDebugInfo());
-
- Exception cause = new IllegalArgumentException("bad arg");
- InternalException apiException =
- new InternalException(MESSAGE, cause, GrpcStatusCode.of(Code.INTERNAL), NOT_RETRYABLE);
- serviceException = new BaseGrpcServiceException(apiException);
- assertFalse(serviceException.isRetryable());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertEquals(apiException, serviceException.getCause());
- assertEquals(500, serviceException.getCode());
- assertEquals(Code.INTERNAL.name(), serviceException.getReason());
- assertNull(serviceException.getLocation());
- assertNull(serviceException.getDebugInfo());
- }
-
- @Test
- public void testTranslateAndThrow() throws Exception {
- IOException exception = new SocketTimeoutException();
- BaseGrpcServiceException cause = new BaseGrpcServiceException(exception, IDEMPOTENT);
- RetryHelper.RetryHelperException exceptionMock =
- createMock(RetryHelper.RetryHelperException.class);
- expect(exceptionMock.getCause()).andReturn(cause).times(2);
- replay(exceptionMock);
- try {
- BaseServiceException.translate(exceptionMock);
- } catch (BaseServiceException ex) {
- assertEquals(0, ex.getCode());
- assertNull(ex.getMessage());
- assertTrue(ex.isRetryable());
- } finally {
- verify(exceptionMock);
- }
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java b/google-cloud-clients/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java
deleted file mode 100644
index b51eab96ce89..000000000000
--- a/google-cloud-clients/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.grpc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import com.google.cloud.grpc.GrpcTransportOptions.DefaultExecutorFactory;
-import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory;
-import java.util.concurrent.ScheduledExecutorService;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class GrpcTransportOptionsTest {
-
- private static final ExecutorFactory MOCK_EXECUTOR_FACTORY =
- EasyMock.createMock(ExecutorFactory.class);
- private static final GrpcTransportOptions OPTIONS =
- GrpcTransportOptions.newBuilder().setExecutorFactory(MOCK_EXECUTOR_FACTORY).build();
- private static final GrpcTransportOptions DEFAULT_OPTIONS =
- GrpcTransportOptions.newBuilder().build();
- private static final GrpcTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build();
-
- @Test
- public void testBuilder() {
- assertSame(MOCK_EXECUTOR_FACTORY, OPTIONS.getExecutorFactory());
- assertTrue(DEFAULT_OPTIONS.getExecutorFactory() instanceof DefaultExecutorFactory);
- }
-
- @Test
- public void testBaseEquals() {
- assertEquals(OPTIONS, OPTIONS_COPY);
- assertNotEquals(DEFAULT_OPTIONS, OPTIONS);
- GrpcTransportOptions options =
- OPTIONS.toBuilder().setExecutorFactory(new DefaultExecutorFactory()).build();
- assertNotEquals(OPTIONS, options);
- }
-
- @Test
- public void testBaseHashCode() {
- assertEquals(OPTIONS.hashCode(), OPTIONS_COPY.hashCode());
- assertNotEquals(DEFAULT_OPTIONS.hashCode(), OPTIONS.hashCode());
- GrpcTransportOptions options =
- OPTIONS.toBuilder().setExecutorFactory(new DefaultExecutorFactory()).build();
- assertNotEquals(OPTIONS.hashCode(), options.hashCode());
- }
-
- @Test
- public void testDefaultExecutorFactory() {
- ExecutorFactory executorFactory = new DefaultExecutorFactory();
- ScheduledExecutorService executorService = executorFactory.get();
- assertSame(executorService, executorFactory.get());
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-http/README.md b/google-cloud-clients/google-cloud-core-http/README.md
new file mode 100644
index 000000000000..f30f9476218f
--- /dev/null
+++ b/google-cloud-clients/google-cloud-core-http/README.md
@@ -0,0 +1,3 @@
+# Google Cloud Java Client -- Core HTTP extensions
+
+This client has moved to https://github.com/googleapis/java-core
\ No newline at end of file
diff --git a/google-cloud-clients/google-cloud-core-http/pom.xml b/google-cloud-clients/google-cloud-core-http/pom.xml
deleted file mode 100644
index dc4b39ae6ec8..000000000000
--- a/google-cloud-clients/google-cloud-core-http/pom.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
- 4.0.0
- google-cloud-core-http
- 1.90.1-SNAPSHOT
- jar
- Google Cloud Core HTTP
- https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http
-
- Core http module for the google-cloud.
-
-
- com.google.cloud
- google-cloud-clients
- 0.108.1-alpha-SNAPSHOT
-
-
- google-cloud-core-http
-
-
-
- com.google.cloud
- google-cloud-core
-
-
- com.google.auth
- google-auth-library-credentials
-
-
- com.google.auth
- google-auth-library-oauth2-http
-
-
- com.google.http-client
- google-http-client
- compile
-
-
- com.google.guava
- guava
-
-
- com.google.api-client
- google-api-client
- compile
-
-
- com.google.http-client
- google-http-client-appengine
- compile
-
-
- com.google.api
- gax-httpjson
-
-
-
-
- junit
- junit
- test
-
-
- org.easymock
- easymock
- test
-
-
- org.objenesis
- objenesis
- test
-
-
- com.google.truth
- truth
- test
-
-
-
diff --git a/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/BaseHttpServiceException.java b/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/BaseHttpServiceException.java
deleted file mode 100644
index 26f43b276f03..000000000000
--- a/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/BaseHttpServiceException.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.http;
-
-import com.google.api.client.googleapis.json.GoogleJsonError;
-import com.google.api.client.googleapis.json.GoogleJsonResponseException;
-import com.google.api.client.http.HttpResponseException;
-import com.google.api.core.InternalApi;
-import com.google.cloud.BaseServiceException;
-import com.google.common.base.MoreObjects;
-import java.io.IOException;
-import java.util.Set;
-
-/** Base class for all exceptions from http-based services. */
-public class BaseHttpServiceException extends BaseServiceException {
-
- private static final long serialVersionUID = -5793034110344127954L;
- public static final int UNKNOWN_CODE = 0;
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseHttpServiceException(
- IOException exception, boolean idempotent, Set retryableErrors) {
- super(makeExceptionData(exception, idempotent, retryableErrors));
- }
-
- private static ExceptionData makeExceptionData(
- IOException exception, boolean idempotent, Set retryableErrors) {
- int code = UNKNOWN_CODE;
- String reason = null;
- String location = null;
- String debugInfo = null;
- Boolean retryable = null;
- if (exception instanceof HttpResponseException) {
- if (exception instanceof GoogleJsonResponseException) {
- GoogleJsonError jsonError = ((GoogleJsonResponseException) exception).getDetails();
- if (jsonError != null) {
- BaseServiceException.Error error =
- new BaseServiceException.Error(jsonError.getCode(), reason(jsonError));
- code = error.getCode();
- reason = error.getReason();
- retryable = error.isRetryable(idempotent, retryableErrors);
- if (reason != null) {
- GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0);
- location = errorInfo.getLocation();
- debugInfo = (String) errorInfo.get("debugInfo");
- }
- } else {
- code = ((GoogleJsonResponseException) exception).getStatusCode();
- retryable = BaseServiceException.isRetryable(code, null, idempotent, retryableErrors);
- }
- } else {
- // In cases where an exception is an instance of HttpResponseException but not
- // an instance of GoogleJsonResponseException, check the status code to determine whether
- // it's retryable
- code = ((HttpResponseException) exception).getStatusCode();
- retryable = BaseServiceException.isRetryable(code, null, idempotent, retryableErrors);
- }
- }
- return ExceptionData.newBuilder()
- .setMessage(message(exception))
- .setCause(exception)
- .setRetryable(
- MoreObjects.firstNonNull(
- retryable, BaseServiceException.isRetryable(idempotent, exception)))
- .setCode(code)
- .setReason(reason)
- .setLocation(location)
- .setDebugInfo(debugInfo)
- .build();
- }
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseHttpServiceException(
- GoogleJsonError googleJsonError,
- boolean idempotent,
- Set retryableErrors) {
- super(makeExceptionData(googleJsonError, idempotent, retryableErrors));
- }
-
- private static ExceptionData makeExceptionData(
- GoogleJsonError googleJsonError,
- boolean idempotent,
- Set retryableErrors) {
- int code = googleJsonError.getCode();
- String reason = reason(googleJsonError);
-
- ExceptionData.Builder exceptionData = ExceptionData.newBuilder();
- exceptionData
- .setMessage(googleJsonError.getMessage())
- .setCause(null)
- .setRetryable(BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors))
- .setCode(code)
- .setReason(reason);
- if (reason != null) {
- GoogleJsonError.ErrorInfo errorInfo = googleJsonError.getErrors().get(0);
- exceptionData.setLocation(errorInfo.getLocation());
- exceptionData.setDebugInfo((String) errorInfo.get("debugInfo"));
- } else {
- exceptionData.setLocation(null);
- exceptionData.setDebugInfo(null);
- }
- return exceptionData.build();
- }
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseHttpServiceException(
- int code,
- String message,
- String reason,
- boolean idempotent,
- Set retryableErrors) {
- this(code, message, reason, idempotent, retryableErrors, null);
- }
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseHttpServiceException(
- int code,
- String message,
- String reason,
- boolean idempotent,
- Set retryableErrors,
- Throwable cause) {
- super(
- ExceptionData.newBuilder()
- .setMessage(message)
- .setCause(cause)
- .setRetryable(
- BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors))
- .setCode(code)
- .setReason(reason)
- .setLocation(null)
- .setDebugInfo(null)
- .build());
- }
-
- private static String reason(GoogleJsonError error) {
- if (error.getErrors() != null && !error.getErrors().isEmpty()) {
- return error.getErrors().get(0).getReason();
- }
- return null;
- }
-
- private static String message(IOException exception) {
- if (exception instanceof GoogleJsonResponseException) {
- GoogleJsonError details = ((GoogleJsonResponseException) exception).getDetails();
- if (details != null) {
- return details.getMessage();
- }
- }
- return exception.getMessage();
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java b/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java
deleted file mode 100644
index d141507cc09b..000000000000
--- a/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2018 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.http;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.api.client.http.HttpExecuteInterceptor;
-import com.google.api.client.http.HttpHeaders;
-import com.google.api.client.http.HttpRequest;
-import com.google.api.client.http.HttpRequestInitializer;
-import com.google.common.annotations.VisibleForTesting;
-import io.opencensus.contrib.http.util.HttpPropagationUtil;
-import io.opencensus.trace.SpanContext;
-import io.opencensus.trace.Tracer;
-import io.opencensus.trace.propagation.TextFormat;
-import java.io.IOException;
-import javax.annotation.Nullable;
-
-/**
- * Provides utilities for Open Census to record http stats/trace information and propagate tracing
- * context.
- */
-public final class CensusHttpModule {
-
- /**
- * OpenCensus tracing component. When no OpenCensus implementation is provided, it will return a
- * no-op tracer.
- */
- private final Tracer tracer;
-
- /** {@link TextFormat} used in tracing context propagation. */
- @Nullable private final TextFormat propagationTextFormat;
-
- /** {@link TextFormat.Setter} for {@link #propagationTextFormat}. */
- @Nullable private final TextFormat.Setter propagationTextFormatSetter;
-
- /** Whether spans are stored locally. */
- private final boolean isRecordEvents;
-
- /** Default HTTP propagation text formatter. */
- @VisibleForTesting
- static final class DefaultPropagationTextFormatSetter extends TextFormat.Setter {
- static final TextFormat.Setter INSTANCE = new DefaultPropagationTextFormatSetter();
-
- @Override
- public void put(HttpHeaders carrier, String key, String value) {
- carrier.set(key, value);
- }
- }
-
- /**
- * An {@link HttpExecuteInterceptor} implementation to inject HTTP request and add getContext
- * information before it is executed.
- */
- @VisibleForTesting
- final class CensusHttpExecuteInterceptor implements HttpExecuteInterceptor {
- @Nullable HttpExecuteInterceptor interceptor;
-
- CensusHttpExecuteInterceptor(HttpExecuteInterceptor interceptor) {
- this.interceptor = interceptor;
- }
-
- @Override
- public void intercept(HttpRequest request) throws IOException {
- checkNotNull(request);
- if (this.interceptor != null) {
- this.interceptor.intercept(request);
- }
- if (propagationTextFormat != null && propagationTextFormatSetter != null) {
- SpanContext spanContext = tracer.getCurrentSpan().getContext();
- if (!SpanContext.INVALID.equals(spanContext)) {
- propagationTextFormat.inject(
- spanContext, request.getHeaders(), propagationTextFormatSetter);
- }
- }
- }
- }
-
- /**
- * An {@link HttpRequestInitializer} implementation to set {@link CensusHttpExecuteInterceptor} as
- * interceptor.
- */
- @VisibleForTesting
- final class CensusHttpRequestInitializer implements HttpRequestInitializer {
- @Nullable HttpRequestInitializer initializer;
-
- CensusHttpRequestInitializer(HttpRequestInitializer initializer) {
- this.initializer = initializer;
- }
-
- @Override
- public void initialize(HttpRequest request) throws IOException {
- checkNotNull(request);
- if (this.initializer != null) {
- this.initializer.initialize(request);
- }
- request.setInterceptor(new CensusHttpExecuteInterceptor(request.getInterceptor()));
- }
- }
-
- /**
- * Creates a {@link CensusHttpModule} with given parameters.
- *
- * @param tracer the OpenCensus {@code Tracer}.
- * @param isRecordEvents whether spans are stored locally.
- */
- public CensusHttpModule(Tracer tracer, boolean isRecordEvents) {
- checkNotNull(tracer, "tracer");
- this.tracer = tracer;
- this.isRecordEvents = isRecordEvents;
- this.propagationTextFormat = HttpPropagationUtil.getCloudTraceFormat();
- this.propagationTextFormatSetter = DefaultPropagationTextFormatSetter.INSTANCE;
- }
-
- /**
- * Returns the tracing component of OpenCensus.
- *
- * @return the tracing component of OpenCensus.
- */
- public Tracer getTracer() {
- return tracer;
- }
-
- /**
- * Returns whether spans are stored locally.
- *
- * @return whether spans are stored locally.
- */
- public boolean isRecordEvents() {
- return isRecordEvents;
- }
-
- /**
- * Returns the {@link HttpExecuteInterceptor} used when initializing the {@link HttpRequest}.
- *
- * @param initializer the original initializer which will be executed before this initializer.
- * @return the {@code HttpExecuteInterceptor}.
- */
- public HttpRequestInitializer getHttpRequestInitializer(HttpRequestInitializer initializer) {
- return new CensusHttpRequestInitializer(initializer);
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java b/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java
deleted file mode 100644
index 2dbcb018f857..000000000000
--- a/google-cloud-clients/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright 2016 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.http;
-
-import static com.google.common.base.MoreObjects.firstNonNull;
-
-import com.google.api.client.extensions.appengine.http.UrlFetchTransport;
-import com.google.api.client.http.HttpRequest;
-import com.google.api.client.http.HttpRequestInitializer;
-import com.google.api.client.http.HttpTransport;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import com.google.api.gax.core.GaxProperties;
-import com.google.api.gax.httpjson.HttpHeadersUtils;
-import com.google.api.gax.rpc.ApiClientHeaderProvider;
-import com.google.api.gax.rpc.HeaderProvider;
-import com.google.auth.Credentials;
-import com.google.auth.http.HttpCredentialsAdapter;
-import com.google.auth.http.HttpTransportFactory;
-import com.google.cloud.NoCredentials;
-import com.google.cloud.PlatformInformation;
-import com.google.cloud.ServiceOptions;
-import com.google.cloud.TransportOptions;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Objects;
-
-/** Class representing service options for those services that use HTTP as the transport layer. */
-public class HttpTransportOptions implements TransportOptions {
-
- private static final long serialVersionUID = 7890117765045419810L;
- private final int connectTimeout;
- private final int readTimeout;
- private final String httpTransportFactoryClassName;
-
- private transient HttpTransportFactory httpTransportFactory;
-
- public static class DefaultHttpTransportFactory implements HttpTransportFactory {
-
- private static final HttpTransportFactory INSTANCE = new DefaultHttpTransportFactory();
-
- @Override
- public HttpTransport create() {
- // Consider App Engine Standard
- if (PlatformInformation.isOnGAEStandard7()) {
- try {
- return new UrlFetchTransport();
- } catch (Exception ignore) {
- // Maybe not on App Engine
- }
- }
- return new NetHttpTransport();
- }
- }
-
- /** Builder for {@code HttpTransportOptions}. */
- public static class Builder {
-
- private HttpTransportFactory httpTransportFactory;
- private int connectTimeout = -1;
- private int readTimeout = -1;
-
- private Builder() {}
-
- private Builder(HttpTransportOptions options) {
- httpTransportFactory = options.httpTransportFactory;
- connectTimeout = options.connectTimeout;
- readTimeout = options.readTimeout;
- }
-
- public HttpTransportOptions build() {
- return new HttpTransportOptions(this);
- }
-
- /**
- * Sets the HTTP transport factory.
- *
- * @return the builder
- */
- public Builder setHttpTransportFactory(HttpTransportFactory httpTransportFactory) {
- this.httpTransportFactory = httpTransportFactory;
- return this;
- }
-
- /**
- * Sets the timeout in milliseconds to establish a connection.
- *
- * @param connectTimeout connection timeout in milliseconds. 0 for an infinite timeout, a
- * negative number for the default value (20000).
- * @return the builder
- */
- public Builder setConnectTimeout(int connectTimeout) {
- this.connectTimeout = connectTimeout;
- return this;
- }
-
- /**
- * Sets the timeout in milliseconds to read data from an established connection.
- *
- * @param readTimeout read timeout in milliseconds. 0 for an infinite timeout, a negative number
- * for the default value (20000).
- * @return the builder
- */
- public Builder setReadTimeout(int readTimeout) {
- this.readTimeout = readTimeout;
- return this;
- }
- }
-
- public HttpTransportOptions(Builder builder) {
- httpTransportFactory =
- firstNonNull(
- builder.httpTransportFactory,
- ServiceOptions.getFromServiceLoader(
- HttpTransportFactory.class, DefaultHttpTransportFactory.INSTANCE));
- httpTransportFactoryClassName = httpTransportFactory.getClass().getName();
- connectTimeout = builder.connectTimeout;
- readTimeout = builder.readTimeout;
- }
-
- /** Returns the HTTP transport factory. */
- public HttpTransportFactory getHttpTransportFactory() {
- return httpTransportFactory;
- }
-
- /**
- * Returns a request initializer responsible for initializing requests according to service
- * options.
- */
- public HttpRequestInitializer getHttpRequestInitializer(
- final ServiceOptions, ?> serviceOptions) {
- Credentials scopedCredentials = serviceOptions.getScopedCredentials();
- final HttpRequestInitializer delegate =
- scopedCredentials != null && scopedCredentials != NoCredentials.getInstance()
- ? new HttpCredentialsAdapter(scopedCredentials)
- : null;
- HeaderProvider internalHeaderProvider =
- getInternalHeaderProviderBuilder(serviceOptions).build();
- final HeaderProvider headerProvider =
- serviceOptions.getMergedHeaderProvider(internalHeaderProvider);
-
- return new HttpRequestInitializer() {
- @Override
- public void initialize(HttpRequest httpRequest) throws IOException {
- if (delegate != null) {
- delegate.initialize(httpRequest);
- }
- if (connectTimeout >= 0) {
- httpRequest.setConnectTimeout(connectTimeout);
- }
- if (readTimeout >= 0) {
- httpRequest.setReadTimeout(readTimeout);
- }
-
- HttpHeadersUtils.setHeaders(httpRequest.getHeaders(), headerProvider.getHeaders());
- }
- };
- }
-
- ApiClientHeaderProvider.Builder getInternalHeaderProviderBuilder(
- ServiceOptions, ?> serviceOptions) {
- ApiClientHeaderProvider.Builder builder = ApiClientHeaderProvider.newBuilder();
- builder.setClientLibToken(
- ServiceOptions.getGoogApiClientLibName(),
- GaxProperties.getLibraryVersion(serviceOptions.getClass()));
- return builder;
- }
-
- /**
- * Returns the timeout in milliseconds to establish a connection. 0 is an infinite timeout, a
- * negative number is the default value (20000).
- */
- public int getConnectTimeout() {
- return connectTimeout;
- }
-
- /**
- * Returns the timeout in milliseconds to read from an established connection. 0 is an infinite
- * timeout, a negative number is the default value (20000).
- */
- public int getReadTimeout() {
- return readTimeout;
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(httpTransportFactoryClassName, connectTimeout, readTimeout);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- HttpTransportOptions other = (HttpTransportOptions) obj;
- return Objects.equals(httpTransportFactoryClassName, other.httpTransportFactoryClassName)
- && Objects.equals(connectTimeout, other.connectTimeout)
- && Objects.equals(readTimeout, other.readTimeout);
- }
-
- private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException {
- input.defaultReadObject();
- httpTransportFactory = ServiceOptions.newInstance(httpTransportFactoryClassName);
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/BaseHttpServiceExceptionTest.java b/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/BaseHttpServiceExceptionTest.java
deleted file mode 100644
index e88a32a9afda..000000000000
--- a/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/BaseHttpServiceExceptionTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.http;
-
-import static com.google.cloud.BaseServiceException.UNKNOWN_CODE;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import com.google.api.client.googleapis.json.GoogleJsonError;
-import com.google.cloud.BaseServiceException;
-import com.google.cloud.RetryHelper;
-import com.google.common.collect.ImmutableSet;
-import java.io.IOException;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.util.Collections;
-import java.util.Set;
-import org.junit.Test;
-
-public class BaseHttpServiceExceptionTest {
-
- private static final int CODE = 1;
- private static final int CODE_NO_REASON = 2;
- private static final String MESSAGE = "some message";
- private static final String REASON = "some reason";
- private static final boolean RETRYABLE = true;
- private static final boolean IDEMPOTENT = true;
- private static final boolean NOT_IDEMPOTENT = false;
- private static final Set EMPTY_RETRYABLE_ERRORS =
- Collections.emptySet();
-
- private static class CustomServiceException extends BaseHttpServiceException {
-
- private static final long serialVersionUID = -195251309124875103L;
-
- public CustomServiceException(int code, String message, String reason, boolean idempotent) {
- super(code, message, reason, idempotent, RETRYABLE_ERRORS);
- }
-
- private static final Set RETRYABLE_ERRORS =
- ImmutableSet.of(
- new Error(CODE, REASON), new Error(null, REASON), new Error(CODE_NO_REASON, null));
- }
-
- @Test
- public void testBaseServiceException() {
- BaseServiceException serviceException =
- new BaseHttpServiceException(CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
- assertEquals(CODE, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertEquals(REASON, serviceException.getReason());
- assertFalse(serviceException.isRetryable());
- assertNull(serviceException.getCause());
-
- serviceException =
- new BaseHttpServiceException(CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
- assertEquals(CODE, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertEquals(REASON, serviceException.getReason());
- assertFalse(serviceException.isRetryable());
- assertNull(serviceException.getCause());
-
- Exception cause = new RuntimeException();
- serviceException =
- new BaseHttpServiceException(
- CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS, cause);
- assertEquals(CODE, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertEquals(REASON, serviceException.getReason());
- assertFalse(serviceException.isRetryable());
- assertEquals(cause, serviceException.getCause());
-
- serviceException =
- new BaseHttpServiceException(
- CODE, MESSAGE, REASON, NOT_IDEMPOTENT, EMPTY_RETRYABLE_ERRORS, cause);
- assertEquals(CODE, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertEquals(REASON, serviceException.getReason());
- assertFalse(serviceException.isRetryable());
- assertEquals(cause, serviceException.getCause());
-
- IOException exception = new SocketTimeoutException();
- serviceException = new BaseHttpServiceException(exception, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
- assertTrue(serviceException.isRetryable());
- assertNull(serviceException.getMessage());
- assertEquals(exception, serviceException.getCause());
-
- exception = new SocketException();
- serviceException = new BaseHttpServiceException(exception, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
- assertTrue(serviceException.isRetryable());
- assertNull(serviceException.getMessage());
- assertEquals(exception, serviceException.getCause());
-
- exception = new IOException("insufficient data written");
- serviceException = new BaseHttpServiceException(exception, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
- assertTrue(serviceException.isRetryable());
- assertEquals("insufficient data written", serviceException.getMessage());
- assertEquals(exception, serviceException.getCause());
-
- GoogleJsonError error = new GoogleJsonError();
- error.setCode(CODE);
- error.setMessage(MESSAGE);
- serviceException = new BaseHttpServiceException(error, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
- assertEquals(CODE, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertFalse(serviceException.isRetryable());
-
- serviceException = new CustomServiceException(CODE, MESSAGE, REASON, IDEMPOTENT);
- assertEquals(CODE, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertEquals(REASON, serviceException.getReason());
- assertEquals(RETRYABLE, serviceException.isRetryable());
-
- serviceException = new CustomServiceException(CODE_NO_REASON, MESSAGE, null, IDEMPOTENT);
- assertEquals(CODE_NO_REASON, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertNull(serviceException.getReason());
- assertEquals(RETRYABLE, serviceException.isRetryable());
-
- serviceException = new CustomServiceException(UNKNOWN_CODE, MESSAGE, REASON, IDEMPOTENT);
- assertEquals(UNKNOWN_CODE, serviceException.getCode());
- assertEquals(MESSAGE, serviceException.getMessage());
- assertEquals(REASON, serviceException.getReason());
- assertEquals(RETRYABLE, serviceException.isRetryable());
- }
-
- @Test
- public void testTranslateAndThrow() throws Exception {
- BaseServiceException cause =
- new BaseHttpServiceException(CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS);
- RetryHelper.RetryHelperException exceptionMock =
- createMock(RetryHelper.RetryHelperException.class);
- expect(exceptionMock.getCause()).andReturn(cause).times(2);
- replay(exceptionMock);
- try {
- BaseServiceException.translate(exceptionMock);
- } catch (BaseServiceException ex) {
- assertEquals(CODE, ex.getCode());
- assertEquals(MESSAGE, ex.getMessage());
- assertFalse(ex.isRetryable());
- } finally {
- verify(exceptionMock);
- }
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/CensusHttpModuleTest.java b/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/CensusHttpModuleTest.java
deleted file mode 100644
index c04d0647fb47..000000000000
--- a/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/CensusHttpModuleTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2018 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.http;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import com.google.api.client.http.GenericUrl;
-import com.google.api.client.http.HttpExecuteInterceptor;
-import com.google.api.client.http.HttpHeaders;
-import com.google.api.client.http.HttpRequest;
-import com.google.api.client.http.HttpRequestInitializer;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import io.opencensus.common.Scope;
-import io.opencensus.trace.Span;
-import io.opencensus.trace.SpanContext;
-import io.opencensus.trace.SpanId;
-import io.opencensus.trace.TraceId;
-import io.opencensus.trace.TraceOptions;
-import io.opencensus.trace.Tracer;
-import io.opencensus.trace.Tracestate;
-import io.opencensus.trace.Tracing;
-import io.opencensus.trace.propagation.TextFormat;
-import java.io.IOException;
-import java.util.EnumSet;
-import java.util.Random;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/** Tests for {@link CensusHttpModule}. */
-@RunWith(JUnit4.class)
-public class CensusHttpModuleTest {
-
- @Rule public final ExpectedException thrown = ExpectedException.none();
-
- private final Tracer tracer = Tracing.getTracer();
- private final CensusHttpModule censusHttpModule = new CensusHttpModule(tracer, false);
- private HttpRequest httpRequest;
-
- @Before
- public void setUp() throws IOException {
- httpRequest =
- new NetHttpTransport()
- .createRequestFactory()
- .buildRequest("GET", new GenericUrl("https://www.google.com"), null);
- }
-
- @Test
- public void tracerShouldNotBeNull() {
- assertThat(censusHttpModule.getTracer()).isNotNull();
- }
-
- @Test
- public void isRecordEventsShouldBeSet() {
- assertThat(censusHttpModule.isRecordEvents()).isEqualTo(false);
- }
-
- @Test
- public void getHttpRequestInitializerShouldReturnCorrectClass() {
- HttpRequestInitializer initializer = censusHttpModule.getHttpRequestInitializer(null);
- assertThat(initializer).isInstanceOf(CensusHttpModule.CensusHttpRequestInitializer.class);
- }
-
- @Test
- public void implementationOfDefaultTextFormatSetter() {
- String testKey = "testKey";
- String testValue = "testValue";
- TextFormat.Setter setter =
- CensusHttpModule.DefaultPropagationTextFormatSetter.INSTANCE;
- setter.put(httpRequest.getHeaders(), testKey, testValue);
- assertThat(httpRequest.getHeaders().get(testKey)).isEqualTo(testValue);
- }
-
- @Test
- public void censusHttpExecuteInterceptorDisallowNullRequest() throws IOException {
- HttpExecuteInterceptor interceptor = censusHttpModule.new CensusHttpExecuteInterceptor(null);
- thrown.expect(NullPointerException.class);
- interceptor.intercept(null);
- }
-
- @Test
- public void censusHttpExecuteInterceptorShouldExecuteOriginal() throws IOException {
- HttpExecuteInterceptor mockInterceptor = createMock(HttpExecuteInterceptor.class);
- HttpExecuteInterceptor censusInterceptor =
- censusHttpModule.new CensusHttpExecuteInterceptor(mockInterceptor);
- mockInterceptor.intercept(httpRequest);
- replay(mockInterceptor);
- censusInterceptor.intercept(httpRequest);
- verify(mockInterceptor);
- }
-
- @Test
- public void censusHttpExecuteInterceptorShouldInjectHeader() throws IOException {
- Random random = new Random();
- SpanContext spanContext =
- SpanContext.create(
- TraceId.generateRandomId(random),
- SpanId.generateRandomId(random),
- TraceOptions.DEFAULT,
- Tracestate.builder().build());
- Span mockSpan =
- createMockBuilder(Span.class)
- .withConstructor(SpanContext.class, EnumSet.class)
- .withArgs(spanContext, null)
- .createMock();
- Scope scope = tracer.withSpan(mockSpan);
- try {
- HttpExecuteInterceptor interceptor = censusHttpModule.new CensusHttpExecuteInterceptor(null);
- interceptor.intercept(httpRequest);
- assertThat(httpRequest.getHeaders().get("X-Cloud-Trace-Context")).isNotNull();
- } finally {
- scope.close();
- }
- }
-
- @Test
- public void censusHttpRequestInitializerDisallowNullRequest() throws IOException {
- HttpRequestInitializer initializer = censusHttpModule.getHttpRequestInitializer(null);
- thrown.expect(NullPointerException.class);
- initializer.initialize(null);
- }
-
- @Test
- public void censusHttpRequestInitializerShouldExecuteOriginal() throws IOException {
- HttpRequestInitializer mockOriginalInitializer = createMock(HttpRequestInitializer.class);
- HttpRequestInitializer censusInitializer =
- censusHttpModule.getHttpRequestInitializer(mockOriginalInitializer);
- mockOriginalInitializer.initialize(httpRequest);
- replay(mockOriginalInitializer);
- censusInitializer.initialize(httpRequest);
- verify(mockOriginalInitializer);
- }
-
- @Test
- public void censusHttpRequestInitializerShouldSetInterceptor() throws IOException {
- censusHttpModule.getHttpRequestInitializer(null).initialize(httpRequest);
- assertThat(httpRequest.getInterceptor())
- .isInstanceOf(CensusHttpModule.CensusHttpExecuteInterceptor.class);
- }
-}
diff --git a/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/HttpTransportOptionsTest.java b/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/HttpTransportOptionsTest.java
deleted file mode 100644
index 1ff7871aec4e..000000000000
--- a/google-cloud-clients/google-cloud-core-http/src/test/java/com/google/cloud/http/HttpTransportOptionsTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud.http;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import com.google.api.gax.rpc.HeaderProvider;
-import com.google.auth.http.HttpTransportFactory;
-import com.google.cloud.ServiceOptions;
-import com.google.cloud.http.HttpTransportOptions.DefaultHttpTransportFactory;
-import java.util.regex.Pattern;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class HttpTransportOptionsTest {
-
- private static final HttpTransportFactory MOCK_HTTP_TRANSPORT_FACTORY =
- EasyMock.createMock(HttpTransportFactory.class);
- private static final HttpTransportOptions OPTIONS =
- HttpTransportOptions.newBuilder()
- .setConnectTimeout(1234)
- .setHttpTransportFactory(MOCK_HTTP_TRANSPORT_FACTORY)
- .setReadTimeout(5678)
- .build();
- private static final HttpTransportOptions DEFAULT_OPTIONS =
- HttpTransportOptions.newBuilder().build();
- private static final HttpTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build();
-
- @Test
- public void testBuilder() {
- assertEquals(1234, OPTIONS.getConnectTimeout());
- assertSame(MOCK_HTTP_TRANSPORT_FACTORY, OPTIONS.getHttpTransportFactory());
- assertEquals(5678, OPTIONS.getReadTimeout());
- assertEquals(-1, DEFAULT_OPTIONS.getConnectTimeout());
- assertTrue(DEFAULT_OPTIONS.getHttpTransportFactory() instanceof DefaultHttpTransportFactory);
- assertEquals(-1, DEFAULT_OPTIONS.getReadTimeout());
- }
-
- @Test
- public void testBaseEquals() {
- assertEquals(OPTIONS, OPTIONS_COPY);
- assertNotEquals(DEFAULT_OPTIONS, OPTIONS);
- }
-
- @Test
- public void testBaseHashCode() {
- assertEquals(OPTIONS.hashCode(), OPTIONS_COPY.hashCode());
- assertNotEquals(DEFAULT_OPTIONS.hashCode(), OPTIONS.hashCode());
- }
-
- @Test
- public void testHeader() {
- String expectedHeaderPattern = "^gl-java/.+ gccl/.* gax/.+";
- ServiceOptions, ?> serviceOptions = EasyMock.createMock(ServiceOptions.class);
- HeaderProvider headerProvider =
- OPTIONS.getInternalHeaderProviderBuilder(serviceOptions).build();
-
- assertEquals(1, headerProvider.getHeaders().size());
- assertTrue(
- Pattern.compile(expectedHeaderPattern)
- .matcher(headerProvider.getHeaders().values().iterator().next())
- .find());
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/README.md b/google-cloud-clients/google-cloud-core/README.md
index fd2b536604e3..5723b282752c 100644
--- a/google-cloud-clients/google-cloud-core/README.md
+++ b/google-cloud-clients/google-cloud-core/README.md
@@ -1,69 +1,3 @@
-Google Cloud Java Client -- Core
-=========================================
+# Google Cloud Java Client -- Core
-This module provides common functionality required by service-specific modules of this library.
-
-[](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.html)
-[](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-core.svg)
-[](https://www.codacy.com/app/mziccard/google-cloud-java)
-
-- [API Documentation](https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/package-summary.html)
-
-Quickstart
-----------
-
-[//]: # ({x-version-update-start:google-cloud-core:released})
-If you are using Maven, add this to your pom.xml file
-```xml
-
- com.google.cloud
- google-cloud-core
- 1.90.0
-
-```
-If you are using Gradle, add this to your dependencies
-```Groovy
-compile 'com.google.cloud:google-cloud-core:1.90.0'
-```
-If you are using SBT, add this to your dependencies
-```Scala
-libraryDependencies += "com.google.cloud" % "google-cloud-core" % "1.90.0"
-```
-[//]: # ({x-version-update-end})
-
-Troubleshooting
----------------
-
-To get help, follow the instructions in the [shared Troubleshooting document](https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
-
-Java Versions
--------------
-
-Java 7 or above is required for using this client.
-
-Contributing
-------------
-
-Contributions to this library are always welcome and highly encouraged.
-
-See `google-cloud`'s [CONTRIBUTING] documentation and the [shared documentation](https://github.com/googleapis/google-cloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
-
-Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
-
-Versioning
-----------
-
-This library follows [Semantic Versioning](http://semver.org/).
-
-It is currently in major version one (``1.y.z``), which means that the public API should be considered stable.
-
-License
--------
-
-Apache 2.0 - See [LICENSE] for more information.
-
-
-[CONTRIBUTING]:https://github.com/googleapis/google-cloud-java/blob/master/CONTRIBUTING.md
-[code-of-conduct]:https://github.com/googleapis/google-cloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
-[LICENSE]: https://github.com/googleapis/google-cloud-java/blob/master/LICENSE
-[cloud-platform]: https://cloud.google.com/
+This client has moved to https://github.com/googleapis/java-core
\ No newline at end of file
diff --git a/google-cloud-clients/google-cloud-core/pom.xml b/google-cloud-clients/google-cloud-core/pom.xml
deleted file mode 100644
index fd281c6f4939..000000000000
--- a/google-cloud-clients/google-cloud-core/pom.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
- 4.0.0
- google-cloud-core
- 1.90.1-SNAPSHOT
- jar
- Google Cloud Core
- https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core
-
- Core module for the google-cloud.
-
-
- com.google.cloud
- google-cloud-clients
- 0.108.1-alpha-SNAPSHOT
-
-
- google-cloud-core
-
-
-
- junit
- junit
- test
-
-
- org.easymock
- easymock
- test
-
-
- org.objenesis
- objenesis
- test
-
-
- com.google.api
- gax
-
-
- com.google.protobuf
- protobuf-java-util
-
-
- com.google.api.grpc
- proto-google-common-protos
-
-
- com.google.api.grpc
- proto-google-iam-v1
-
-
- com.google.truth
- truth
- test
-
-
- com.google.guava
- guava-testlib
- test
-
-
-
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/AsyncPageImpl.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/AsyncPageImpl.java
deleted file mode 100644
index 25cae6f7c8d4..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/AsyncPageImpl.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2016 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import com.google.api.core.ApiFuture;
-import com.google.api.core.ApiFutures;
-import com.google.api.core.InternalApi;
-import com.google.api.gax.paging.AsyncPage;
-import com.google.api.gax.paging.Page;
-import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.Uninterruptibles;
-import java.io.Serializable;
-import java.util.concurrent.ExecutionException;
-
-/**
- * Base implementation for asynchronously consuming Google Cloud paginated results.
- *
- * @param the value type that the page holds
- */
-@InternalApi
-public class AsyncPageImpl extends PageImpl implements AsyncPage {
-
- private static final long serialVersionUID = -6009473188630364906L;
-
- private final NextPageFetcher asyncPageFetcher;
-
- /**
- * Interface for asynchronously fetching the next page of results from the service.
- *
- * @param the value type that the page holds
- */
- public interface NextPageFetcher extends Serializable {
-
- ApiFuture> getNextPage();
- }
-
- private static class SyncNextPageFetcher implements PageImpl.NextPageFetcher {
-
- private static final long serialVersionUID = -4124568632363525351L;
-
- private final NextPageFetcher asyncPageFetcher;
-
- private SyncNextPageFetcher(NextPageFetcher asyncPageFetcher) {
- this.asyncPageFetcher = asyncPageFetcher;
- }
-
- @Override
- public Page getNextPage() {
- try {
- return asyncPageFetcher != null
- ? Uninterruptibles.getUninterruptibly(asyncPageFetcher.getNextPage())
- : null;
- } catch (ExecutionException ex) {
- Throwables.throwIfUnchecked(ex.getCause());
- throw new RuntimeException(ex);
- }
- }
- }
-
- /** Creates an {@code AsyncPageImpl} object. */
- public AsyncPageImpl(NextPageFetcher asyncPageFetcher, String cursor, Iterable results) {
- super(new SyncNextPageFetcher(asyncPageFetcher), cursor, results);
- this.asyncPageFetcher = asyncPageFetcher;
- }
-
- @Override
- public ApiFuture> getNextPageAsync() {
- if (getNextPageToken() == null || asyncPageFetcher == null) {
- return ApiFutures.immediateFuture(null);
- }
- return asyncPageFetcher.getNextPage();
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseService.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseService.java
deleted file mode 100644
index 781f29b421a8..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import com.google.api.core.InternalApi;
-import com.google.cloud.ExceptionHandler.Interceptor;
-
-/**
- * Base class for service objects.
- *
- * @param the {@code ServiceOptions} subclass corresponding to the service
- */
-public abstract class BaseService>
- implements Service {
-
- public static final Interceptor EXCEPTION_HANDLER_INTERCEPTOR =
- new Interceptor() {
-
- private static final long serialVersionUID = -8429573486870467828L;
-
- @Override
- public RetryResult afterEval(Exception exception, RetryResult retryResult) {
- return Interceptor.RetryResult.CONTINUE_EVALUATION;
- }
-
- @Override
- public RetryResult beforeEval(Exception exception) {
- if (exception instanceof BaseServiceException) {
- boolean retriable = ((BaseServiceException) exception).isRetryable();
- return retriable
- ? Interceptor.RetryResult.RETRY
- : Interceptor.RetryResult.CONTINUE_EVALUATION;
- }
- return Interceptor.RetryResult.CONTINUE_EVALUATION;
- }
- };
- public static final ExceptionHandler EXCEPTION_HANDLER =
- ExceptionHandler.newBuilder()
- .abortOn(RuntimeException.class)
- .addInterceptors(EXCEPTION_HANDLER_INTERCEPTOR)
- .build();
-
- private final OptionsT options;
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseService(OptionsT options) {
- this.options = options;
- }
-
- @Override
- public OptionsT getOptions() {
- return options;
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java
deleted file mode 100644
index e9e9e2aa6370..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright 2015 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import com.google.api.core.InternalApi;
-import com.google.common.base.MoreObjects;
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.security.cert.CertificateException;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import javax.net.ssl.SSLHandshakeException;
-
-/** Base class for all service exceptions. */
-public class BaseServiceException extends RuntimeException {
-
- private static final long serialVersionUID = 759921776378760835L;
- public static final int UNKNOWN_CODE = 0;
-
- private final int code;
- private final boolean retryable;
- private final String reason;
- private final String location;
- private final String debugInfo;
-
- @InternalApi
- public static final class ExceptionData implements Serializable {
- private static final long serialVersionUID = 2222230861338426753L;
-
- private final String message;
- private final Throwable cause;
- private final int code;
- private final boolean retryable;
- private final String reason;
- private final String location;
- private final String debugInfo;
-
- private ExceptionData(
- String message,
- Throwable cause,
- int code,
- boolean retryable,
- String reason,
- String location,
- String debugInfo) {
- this.message = message;
- this.cause = cause;
- this.code = code;
- this.retryable = retryable;
- this.reason = reason;
- this.location = location;
- this.debugInfo = debugInfo;
- }
-
- public String getMessage() {
- return message;
- }
-
- public Throwable getCause() {
- return cause;
- }
-
- public int getCode() {
- return code;
- }
-
- public boolean isRetryable() {
- return retryable;
- }
-
- public String getReason() {
- return reason;
- }
-
- public String getLocation() {
- return location;
- }
-
- public String getDebugInfo() {
- return debugInfo;
- }
-
- public static Builder newBuilder() {
- return new Builder();
- }
-
- public static ExceptionData from(int code, String message, String reason, boolean retryable) {
- return from(code, message, reason, retryable, null);
- }
-
- public static ExceptionData from(
- int code, String message, String reason, boolean retryable, Throwable cause) {
- return newBuilder()
- .setCode(code)
- .setMessage(message)
- .setReason(reason)
- .setRetryable(retryable)
- .setCause(cause)
- .build();
- }
-
- @InternalApi
- public static final class Builder {
-
- private String message;
- private Throwable cause;
- private int code;
- private boolean retryable;
- private String reason;
- private String location;
- private String debugInfo;
-
- private Builder() {}
-
- public Builder setMessage(String message) {
- this.message = message;
- return this;
- }
-
- public Builder setCause(Throwable cause) {
- this.cause = cause;
- return this;
- }
-
- public Builder setCode(int code) {
- this.code = code;
- return this;
- }
-
- public Builder setRetryable(boolean retryable) {
- this.retryable = retryable;
- return this;
- }
-
- public Builder setReason(String reason) {
- this.reason = reason;
- return this;
- }
-
- public Builder setLocation(String location) {
- this.location = location;
- return this;
- }
-
- public Builder setDebugInfo(String debugInfo) {
- this.debugInfo = debugInfo;
- return this;
- }
-
- public ExceptionData build() {
- return new ExceptionData(message, cause, code, retryable, reason, location, debugInfo);
- }
- }
- }
-
- @InternalApi
- public static final class Error implements Serializable {
-
- private static final long serialVersionUID = -4019600198652965721L;
-
- private final Integer code;
- private final String reason;
- private final boolean rejected;
-
- public Error(Integer code, String reason) {
- this(code, reason, false);
- }
-
- public Error(Integer code, String reason, boolean rejected) {
- this.code = code;
- this.reason = reason;
- this.rejected = rejected;
- }
-
- /** Returns the code associated with this exception. */
- public Integer getCode() {
- return code;
- }
-
- /**
- * Returns true if the error indicates that the API call was certainly not accepted by the
- * server. For instance, if the server returns a rate limit exceeded error, it certainly did not
- * process the request and this method will return {@code true}.
- */
- public boolean isRejected() {
- return rejected;
- }
-
- /** Returns the reason that caused the exception. */
- public String getReason() {
- return reason;
- }
-
- @InternalApi
- public boolean isRetryable(boolean idempotent, Set retryableErrors) {
- return BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("code", code)
- .add("reason", reason)
- .add("rejected", rejected)
- .toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(code, reason, rejected);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Error)) {
- return false;
- }
- Error o = (Error) obj;
- return Objects.equals(code, o.code)
- && Objects.equals(reason, o.reason)
- && Objects.equals(rejected, o.rejected);
- }
- }
-
- @InternalApi
- public static boolean isRetryable(
- Integer code, String reason, boolean idempotent, Set retryableErrors) {
- for (Error retryableError : retryableErrors) {
- if ((retryableError.getCode() == null || retryableError.getCode().equals(code))
- && (retryableError.getReason() == null || retryableError.getReason().equals(reason))) {
- return idempotent || retryableError.isRejected();
- }
- }
- return false;
- }
-
- @InternalApi
- public static boolean isRetryable(boolean idempotent, IOException exception) {
- boolean exceptionIsRetryable =
- exception instanceof SocketTimeoutException
- || exception instanceof SocketException
- || (exception instanceof SSLHandshakeException
- && !(exception.getCause() instanceof CertificateException))
- || "insufficient data written".equals(exception.getMessage())
- || "Error writing request body to server".equals(exception.getMessage());
- return idempotent && exceptionIsRetryable;
- }
-
- @InternalApi
- public static void translate(RetryHelper.RetryHelperException ex) {
- if (ex.getCause() instanceof BaseServiceException) {
- throw (BaseServiceException) ex.getCause();
- }
- }
-
- @InternalApi
- public static void translate(ExecutionException ex) {
- if (ex.getCause() instanceof BaseServiceException) {
- throw (BaseServiceException) ex.getCause();
- }
- }
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseServiceException(ExceptionData exceptionData) {
- super(exceptionData.getMessage(), exceptionData.getCause());
- this.code = exceptionData.getCode();
- this.reason = exceptionData.getReason();
- this.retryable = exceptionData.isRetryable();
- this.location = exceptionData.getLocation();
- this.debugInfo = exceptionData.getDebugInfo();
- }
-
- /** Returns the code associated with this exception. */
- public int getCode() {
- return code;
- }
-
- /** Returns the reason that caused the exception. */
- public String getReason() {
- return reason;
- }
-
- /** Returns {@code true} when it is safe to retry the operation that caused this exception. */
- public boolean isRetryable() {
- return retryable;
- }
-
- /**
- * Returns the service location where the error causing the exception occurred. Returns {@code
- * null} if not available.
- */
- public String getLocation() {
- return location;
- }
-
- @InternalApi
- public String getDebugInfo() {
- return debugInfo;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof BaseServiceException)) {
- return false;
- }
- BaseServiceException other = (BaseServiceException) obj;
- return Objects.equals(getCause(), other.getCause())
- && Objects.equals(getMessage(), other.getMessage())
- && code == other.code
- && retryable == other.retryable
- && Objects.equals(reason, other.reason)
- && Objects.equals(location, other.location)
- && Objects.equals(debugInfo, other.debugInfo);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(getCause(), getMessage(), code, retryable, reason, location, debugInfo);
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java
deleted file mode 100644
index 865af889597d..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright 2015 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import com.google.api.core.InternalApi;
-import java.io.IOException;
-import java.io.Serializable;
-import java.nio.ByteBuffer;
-import java.nio.channels.ClosedChannelException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Base implementation for a {@link WriteChannel}.
- *
- * @param the service options used by the channel to issue RPC requests
- * @param the entity this channel writes data to. Possibly with additional configuration
- */
-public abstract class BaseWriteChannel<
- ServiceOptionsT extends ServiceOptions, ServiceOptionsT>, EntityT extends Serializable>
- implements WriteChannel {
-
- private static final int MIN_CHUNK_SIZE = 256 * 1024;
- private static final int DEFAULT_CHUNK_SIZE = 8 * MIN_CHUNK_SIZE;
-
- private final ServiceOptionsT options;
- private final EntityT entity;
- private final String uploadId;
- private long position;
- private byte[] buffer = new byte[0];
- private int limit;
- private boolean isOpen = true;
- private int chunkSize = getDefaultChunkSize();
-
- protected int getMinChunkSize() {
- return MIN_CHUNK_SIZE;
- }
-
- protected int getDefaultChunkSize() {
- return DEFAULT_CHUNK_SIZE;
- }
-
- /**
- * Writes {@code length} bytes of {@link #getBuffer()} to the {@link #getUploadId()} URL.
- *
- * @param length the number of bytes to write from {@link #getBuffer()}
- * @param last if {@code true} the resumable session is closed
- */
- protected abstract void flushBuffer(int length, boolean last);
-
- protected ServiceOptionsT getOptions() {
- return options;
- }
-
- protected EntityT getEntity() {
- return entity;
- }
-
- protected String getUploadId() {
- return uploadId;
- }
-
- protected long getPosition() {
- return position;
- }
-
- protected byte[] getBuffer() {
- return buffer;
- }
-
- protected int getLimit() {
- return limit;
- }
-
- protected int getChunkSize() {
- return chunkSize;
- }
-
- @Override
- public final void setChunkSize(int chunkSize) {
- int minSize = getMinChunkSize();
-
- this.chunkSize = Math.max(minSize, (chunkSize + minSize - 1) / minSize * minSize);
- }
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId) {
- this.options = options;
- this.entity = entity;
- this.uploadId = uploadId;
- }
-
- private void flush() {
- if (limit >= chunkSize) {
- final int length = limit - limit % getMinChunkSize();
- flushBuffer(length, false);
- position += length;
- limit -= length;
- byte[] temp = new byte[chunkSize];
- System.arraycopy(buffer, length, temp, 0, limit);
- buffer = temp;
- }
- }
-
- private void validateOpen() throws ClosedChannelException {
- if (!isOpen) {
- throw new ClosedChannelException();
- }
- }
-
- @Override
- public final int write(ByteBuffer byteBuffer) throws IOException {
- validateOpen();
- int toWrite = byteBuffer.remaining();
- int spaceInBuffer = buffer.length - limit;
- if (spaceInBuffer >= toWrite) {
- byteBuffer.get(buffer, limit, toWrite);
- } else {
- buffer = Arrays.copyOf(buffer, Math.max(chunkSize, buffer.length + toWrite - spaceInBuffer));
- byteBuffer.get(buffer, limit, toWrite);
- }
- limit += toWrite;
- flush();
- return toWrite;
- }
-
- @Override
- public boolean isOpen() {
- return isOpen;
- }
-
- @Override
- public final void close() throws IOException {
- if (isOpen) {
- flushBuffer(limit, true);
- position += buffer.length;
- isOpen = false;
- buffer = null;
- }
- }
-
- /** Creates a {@link BaseState.Builder} for the current write channel. */
- protected abstract BaseState.Builder stateBuilder();
-
- @Override
- public RestorableState capture() {
- byte[] bufferToSave = null;
- if (isOpen) {
- bufferToSave = Arrays.copyOf(buffer, limit);
- }
- return stateBuilder()
- .setPosition(position)
- .setBuffer(bufferToSave)
- .setIsOpen(isOpen)
- .setChunkSize(chunkSize)
- .build();
- }
-
- /** Restores the state of the current write channel given a {@link BaseState} object. */
- protected void restore(BaseState state) {
- if (state.buffer != null) {
- this.buffer = state.buffer.clone();
- this.limit = state.buffer.length;
- }
- this.position = state.position;
- this.isOpen = state.isOpen;
- this.chunkSize = state.chunkSize;
- }
-
- protected abstract static class BaseState<
- ServiceOptionsT extends ServiceOptions, ServiceOptionsT>, EntityT extends Serializable>
- implements RestorableState, Serializable {
-
- private static final long serialVersionUID = 8541062465055125619L;
-
- protected final ServiceOptionsT serviceOptions;
- protected final EntityT entity;
- protected final String uploadId;
- protected final long position;
- protected final byte[] buffer;
- protected final boolean isOpen;
- protected final int chunkSize;
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BaseState(Builder builder) {
- this.serviceOptions = builder.serviceOptions;
- this.entity = builder.entity;
- this.uploadId = builder.uploadId;
- this.position = builder.position;
- this.buffer = builder.buffer;
- this.isOpen = builder.isOpen;
- this.chunkSize = builder.chunkSize;
- }
-
- /**
- * Base builder for a write channel's state. Users are not supposed to access this class
- * directly.
- *
- * @param the service options used by the channel to issue RPC requests
- * @param the entity this channel writes data to. Possibly with additional
- * configuration
- */
- public abstract static class Builder<
- ServiceOptionsT extends ServiceOptions, ServiceOptionsT>, EntityT extends Serializable> {
- private final ServiceOptionsT serviceOptions;
- private final EntityT entity;
- private final String uploadId;
- private long position;
- private byte[] buffer;
- private boolean isOpen;
- private int chunkSize;
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected Builder(ServiceOptionsT options, EntityT entity, String uploadId) {
- this.serviceOptions = options;
- this.entity = entity;
- this.uploadId = uploadId;
- }
-
- public Builder setPosition(long position) {
- this.position = position;
- return this;
- }
-
- public Builder setBuffer(byte[] buffer) {
- this.buffer = buffer;
- return this;
- }
-
- public Builder setIsOpen(boolean isOpen) {
- this.isOpen = isOpen;
- return this;
- }
-
- public Builder setChunkSize(int chunkSize) {
- this.chunkSize = chunkSize;
- return this;
- }
-
- public abstract RestorableState build();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(
- serviceOptions, entity, uploadId, position, isOpen, chunkSize, Arrays.hashCode(buffer));
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof BaseState)) {
- return false;
- }
- final BaseState other = (BaseState) obj;
- return Objects.equals(this.serviceOptions, other.serviceOptions)
- && Objects.equals(this.entity, other.entity)
- && Objects.equals(this.uploadId, other.uploadId)
- && Objects.deepEquals(this.buffer, other.buffer)
- && this.position == other.position
- && this.isOpen == other.isOpen
- && this.chunkSize == other.chunkSize;
- }
-
- protected static final class ValueHolder {
- final String name;
- final Object value;
-
- private ValueHolder(String name, Object value) {
- this.name = name;
- this.value = value;
- }
-
- public static ValueHolder create(String name, Object value) {
- return new ValueHolder(name, value);
- }
-
- @Override
- public String toString() {
- String result = name + "=";
- if (value != null && value.getClass().isArray()) {
- Object[] objectArray = new Object[] {value};
- String arrayString = Arrays.deepToString(objectArray);
- result += arrayString.substring(1, arrayString.length() - 1);
- } else {
- result += value;
- }
- return result;
- }
- }
-
- protected List toStringHelper() {
- List valueList = new ArrayList<>();
- valueList.add(ValueHolder.create("entity", entity));
- valueList.add(ValueHolder.create("uploadId", uploadId));
- valueList.add(ValueHolder.create("position", String.valueOf(position)));
- valueList.add(ValueHolder.create("isOpen", String.valueOf(isOpen)));
- return valueList;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append(getClass().getSimpleName()).append('{');
- String nextSeparator = "";
- for (ValueHolder valueHolder : toStringHelper()) {
- builder.append(nextSeparator).append(valueHolder);
- nextSeparator = ", ";
- }
- builder.append('}');
- return builder.toString();
- }
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BatchResult.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BatchResult.java
deleted file mode 100644
index 7281571f916b..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/BatchResult.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.api.core.InternalApi;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * This class holds a single result of a batch call. The class is not thread-safe.
- *
- * @param the type of the result
- * @param the type of the service-dependent exception thrown when a processing error occurs
- */
-public abstract class BatchResult {
-
- private T result;
- private boolean completed = false;
- private E error;
- private final List> toBeNotified = new LinkedList<>();
-
- @InternalApi("This class should only be extended within google-cloud-java")
- protected BatchResult() {}
-
- /**
- * Returns {@code true} if the batch has been completed and the result is available; {@code false}
- * otherwise.
- */
- public boolean completed() {
- return completed;
- }
-
- /**
- * Returns the result of this call.
- *
- * @throws IllegalStateException if the batch has not been completed yet
- * @throws E if an error occurred when processing the batch request
- */
- public T get() throws E {
- checkState(completed(), "Batch has not been completed yet");
- if (error != null) {
- throw error;
- }
- return result;
- }
-
- /**
- * Adds a callback for the batch operation.
- *
- * @throws IllegalStateException if the batch has been completed already
- */
- public void notify(Callback callback) {
- checkState(
- !completed,
- "The batch has been completed. All the calls to the notify()"
- + " method should be done prior to submitting the batch.");
- toBeNotified.add(callback);
- }
-
- /** Sets an error and status as completed. Notifies all callbacks. */
- protected void error(E error) {
- this.error = checkNotNull(error);
- this.completed = true;
- for (Callback callback : toBeNotified) {
- callback.error(error);
- }
- }
-
- /** Sets a result and status as completed. Notifies all callbacks. */
- protected void success(T result) {
- this.result = result;
- this.completed = true;
- for (Callback callback : toBeNotified) {
- callback.success(result);
- }
- }
-
- /** An interface for the batch callbacks. */
- public interface Callback {
- /** The method to be called when the batched operation succeeds. */
- void success(T result);
-
- /** The method to be called when the batched operation fails. */
- void error(E exception);
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ByteArray.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ByteArray.java
deleted file mode 100644
index 5841c541c46d..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ByteArray.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright 2016 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import com.google.api.core.BetaApi;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.io.BaseEncoding;
-import com.google.protobuf.ByteString;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-import java.util.Iterator;
-
-/** An immutable byte array holder. */
-@BetaApi
-public class ByteArray implements Iterable, Serializable {
-
- private static final long serialVersionUID = -1908809133893782840L;
- private static final BaseEncoding encoder = BaseEncoding.base64();
-
- private final ByteString byteString;
-
- ByteArray(ByteString byteString) {
- this.byteString = byteString;
- }
-
- @Override
- public final Iterator iterator() {
- return byteString.iterator();
- }
-
- @Override
- public String toString() {
- ToStringHelper toStringHelper = MoreObjects.toStringHelper(this);
- StringBuilder stBuilder = new StringBuilder();
- for (int i = 0; i < Math.min(256, byteString.size()); i++) {
- stBuilder.append(String.format("%02x", byteString.byteAt(i)));
- }
- if (byteString.size() > 256) {
- stBuilder.append("...");
- }
- return toStringHelper.add("bytes", stBuilder.toString()).toString();
- }
-
- @Override
- public final int hashCode() {
- return byteString.hashCode();
- }
-
- @Override
- public final boolean equals(Object obj) {
- return obj == this
- || obj instanceof ByteArray && byteString.equals(((ByteArray) obj).byteString);
- }
-
- /** Returns the number of bytes in this {@code ByteArray}. */
- public final int length() {
- return byteString.size();
- }
-
- /** Returns a copy of this {@code ByteArray} as an array of bytes. */
- public final byte[] toByteArray() {
- return byteString.toByteArray();
- }
-
- /** Returns a copy of this {@code ByteArray} as an {@code UTF-8} string. */
- public final String toStringUtf8() {
- return byteString.toStringUtf8();
- }
-
- /** Converts this byte array to its base64 representation. */
- public final String toBase64() {
- return encoder.encode(toByteArray());
- }
-
- /** Returns the content of this {@code ByteArray} as a read-only {@link ByteBuffer}. */
- public final ByteBuffer asReadOnlyByteBuffer() {
- return byteString.asReadOnlyByteBuffer();
- }
-
- /** Returns an {@link InputStream} for this {@code ByteArray} content. */
- public final InputStream asInputStream() {
- return byteString.newInput();
- }
-
- /**
- * Copies the content of this {@code ByteArray} into an existing {@code ByteBuffer}.
- *
- * @throws java.nio.ReadOnlyBufferException if the target is read-only
- * @throws java.nio.BufferOverflowException if the target's {@link ByteBuffer#remaining()} space
- * is not large enough to hold the data
- */
- public final void copyTo(ByteBuffer target) {
- byteString.copyTo(target);
- }
-
- /**
- * Copies the content of this {@code ByteArray} into an array of bytes.
- *
- * @throws IndexOutOfBoundsException if the target is not large enough to hold the data
- */
- public final void copyTo(byte[] target) {
- byteString.copyTo(target, 0);
- }
-
- /** Creates a {@code ByteArray} object given an array of bytes. The bytes are copied. */
- public static final ByteArray copyFrom(byte[] bytes) {
- return new ByteArray(ByteString.copyFrom(bytes));
- }
-
- /**
- * Creates a {@code ByteArray} object given a string. The string is encoded in {@code UTF-8}. The
- * bytes are copied.
- */
- public static final ByteArray copyFrom(String string) {
- return new ByteArray(ByteString.copyFrom(string, StandardCharsets.UTF_8));
- }
-
- /** Creates a {@code ByteArray} object given a {@link ByteBuffer}. The bytes are copied. */
- public static final ByteArray copyFrom(ByteBuffer bytes) {
- return new ByteArray(ByteString.copyFrom(bytes));
- }
-
- /**
- * Creates a {@code ByteArray} object given an {@link InputStream}. The stream is read into the
- * created object.
- */
- public static final ByteArray copyFrom(InputStream input) throws IOException {
- return new ByteArray(ByteString.readFrom(input));
- }
-
- /** Creates a {@code ByteArray} from a base64 representation. */
- public static ByteArray fromBase64(String data) {
- return ByteArray.copyFrom(encoder.decode(data));
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/Date.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/Date.java
deleted file mode 100644
index d7f3b71275e7..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/Date.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import com.google.api.core.BetaApi;
-import com.google.common.base.Preconditions;
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Objects;
-
-/** Represents a Date without time, such as 2017-03-17. Date is timezone independent. */
-@BetaApi("This is going to be replaced with LocalDate from threetenbp")
-public final class Date implements Comparable, Serializable {
-
- // Date format "yyyy-mm-dd"
- private static final long serialVersionUID = 8067099123096783929L;
- private final int year;
- private final int month;
- private final int dayOfMonth;
-
- private Date(int year, int month, int dayOfMonth) {
- Preconditions.checkArgument(year > 0, "Invalid year: " + year);
- Preconditions.checkArgument(month > 0 && month <= 12, "Invalid month: " + month);
- Preconditions.checkArgument(dayOfMonth > 0 && dayOfMonth <= 31, "Invalid day: " + dayOfMonth);
- this.year = year;
- this.month = month;
- this.dayOfMonth = dayOfMonth;
- }
-
- /**
- * Constructs a new Date instance.
- *
- * @param year must be greater than 0
- * @param month must be between [1,12]
- * @param dayOfMonth must be between [1,31]
- */
- public static Date fromYearMonthDay(int year, int month, int dayOfMonth) {
- return new Date(year, month, dayOfMonth);
- }
-
- /** @param date Data in RFC 3339 date format (yyyy-mm-dd). */
- public static Date parseDate(String date) {
- Preconditions.checkNotNull(date);
- final String invalidDate = "Invalid date: " + date;
- Preconditions.checkArgument(date.length() == 10, invalidDate);
- Preconditions.checkArgument(date.charAt(4) == '-', invalidDate);
- Preconditions.checkArgument(date.charAt(7) == '-', invalidDate);
- try {
- int year = Integer.parseInt(date.substring(0, 4));
- int month = Integer.parseInt(date.substring(5, 7));
- int dayOfMonth = Integer.parseInt(date.substring(8, 10));
- return new Date(year, month, dayOfMonth);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(invalidDate, e);
- }
- }
-
- /**
- * Convert a Google Date to a Java Util Date.
- *
- * @param date the date of the Google Date.
- * @return java.util.Date
- */
- public static java.util.Date toJavaUtilDate(Date date) {
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- // Calender.MONTH starts from 0 while G C date starts from 1
- cal.set(date.year, date.month - 1, date.dayOfMonth);
- return cal.getTime();
- }
-
- /**
- * Convert a Java Util Date to a Google Date.
- *
- * @param date the date of the java.util.Date
- * @return Google Java Date
- */
- public static Date fromJavaUtilDate(java.util.Date date) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- // Calender.MONTH starts from 0 while G C date starts from 1
- return new Date(
- cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH));
- }
-
- /** Returns the year. */
- public int getYear() {
- return year;
- }
-
- /** Returns the month between 1 and 12 inclusive. */
- public int getMonth() {
- return month;
- }
-
- /** Returns day of month between 1 and 31 inclusive. */
- public int getDayOfMonth() {
- return dayOfMonth;
- }
-
- @Override
- public String toString() {
- return String.format("%04d-%02d-%02d", year, month, dayOfMonth);
- }
-
- StringBuilder toString(StringBuilder b) {
- return b.append(toString());
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- Date that = (Date) o;
- return year == that.year && month == that.month && dayOfMonth == that.dayOfMonth;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(year, month, dayOfMonth);
- }
-
- @Override
- public int compareTo(Date other) {
- int r = Integer.compare(year, other.year);
- if (r == 0) {
- r = Integer.compare(month, other.month);
- if (r == 0) {
- r = Integer.compare(dayOfMonth, other.dayOfMonth);
- }
- }
- return r;
- }
-}
diff --git a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java b/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java
deleted file mode 100644
index d243de180771..000000000000
--- a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright 2015 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.cloud;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.api.core.BetaApi;
-import com.google.api.gax.retrying.ResultRetryAlgorithm;
-import com.google.api.gax.retrying.TimedAttemptSettings;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
-/** Exception retry algorithm implementation used by {@link RetryHelper}. */
-@BetaApi
-public final class ExceptionHandler implements ResultRetryAlgorithm