Repository: googleapis/java-bigtable-hbase
Pull request #2837 (2021-02-18 18:57:57)

chore(deps): remove dependency on google-http-client
We unintentionally started depending on google-http-client for for minimal functionality. This will either inline or pull the functionality from elsewhere and drop the dep


Patch:
diff --git a/bigtable-client-core-parent/bigtable-hbase/pom.xml b/bigtable-client-core-parent/bigtable-hbase/pom.xml
index 7bbf20ab4..0c1925ffe 100644
--- a/bigtable-client-core-parent/bigtable-hbase/pom.xml
+++ b/bigtable-client-core-parent/bigtable-hbase/pom.xml
@@ -141,16 +141,10 @@ limitations under the License.
       <artifactId>google-auth-library-oauth2-http</artifactId>
     </dependency>
 
-    <!-- TODO: remove this is direct dep, its only used for its Clock interface -->
-    <dependency>
-      <groupId>com.google.http-client</groupId>
-      <artifactId>google-http-client</artifactId>
-    </dependency>
-
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
       <exclusions>
         <exclusion>
           <groupId>org.slf4j</groupId>
diff --git a/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/PutAdapter.java b/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/PutAdapter.java
index 1259e142d..537905f2a 100644
--- a/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/PutAdapter.java
+++ b/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/adapters/PutAdapter.java
@@ -15,10 +15,8 @@
  */
 package com.google.cloud.bigtable.hbase.adapters;
 
-import com.google.api.client.util.Clock;
 import com.google.api.core.InternalApi;
 import com.google.cloud.bigtable.hbase.util.TimestampConverter;
-import com.google.common.annotations.VisibleForTesting;
 import com.google.protobuf.ByteString;
 import java.util.List;
 import java.util.Map.Entry;
@@ -37,8 +35,6 @@ public class PutAdapter extends MutationAdapter<Put> {
   private final int maxKeyValueSize;
   private final boolean setClientTimestamp;
 
-  @VisibleForTesting Clock clock = Clock.SYSTEM;
-
   /**
    * Constructor for PutAdapter.
    *
@@ -74,7 +70,7 @@ public class PutAdapter extends MutationAdapter<Put> {
 
     // Bigtable uses a 1ms granularity. Use this timestamp if the Put does not have one specified to
     // make mutations idempotent.
-    long currentTimestampMicros = setClientTimestamp ? clock.currentTimeMillis() * 1000 : -1;
+    long currentTimestampMicros = setClientTimestamp ? System.currentTimeMillis() * 1000 : -1;
     final int rowLength = operation.getRow().length;
 
     for (Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) {
diff --git a/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/util/OperationAccountant.java b/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/util/OperationAccountant.java
index 1c6637ff1..d5bd0bd00 100644
--- a/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/util/OperationAccountant.java
+++ b/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/util/OperationAccountant.java
@@ -15,11 +15,12 @@
  */
 package com.google.cloud.bigtable.hbase.util;
 
-import com.google.api.client.util.NanoClock;
+import com.google.api.core.ApiClock;
 import com.google.api.core.ApiFuture;
 import com.google.api.core.ApiFutureCallback;
 import com.google.api.core.ApiFutures;
 import com.google.api.core.InternalApi;
+import com.google.api.core.NanoClock;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.concurrent.TimeUnit;
@@ -42,7 +43,7 @@ public class OperationAccountant {
   // Flush() will still wait to complete.
   private static final long INTERVAL_NO_SUCCESS_WARNING_NANOS = TimeUnit.SECONDS.toNanos(30);
 
-  private final NanoClock clock;
+  private final ApiClock clock;
   private final long finishWaitMillis;
 
   private final Object signal = new String("");
@@ -53,11 +54,11 @@ public class OperationAccountant {
 
   /** Constructor for {@link OperationAccountant}. */
   public OperationAccountant() {
-    this(NanoClock.SYSTEM, DEFAULT_FINISH_WAIT_MILLIS);
+    this(NanoClock.getDefaultClock(), DEFAULT_FINISH_WAIT_MILLIS);
   }
 
   @VisibleForTesting
-  OperationAccountant(NanoClock clock, long finishWaitMillis) {
+  OperationAccountant(ApiClock clock, long finishWaitMillis) {
     this.clock = clock;
     this.finishWaitMillis = finishWaitMillis;
     resetNoSuccessWarningDeadline();
diff --git a/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/wrappers/veneer/BigtableHBaseVeneerSettings.java b/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/wrappers/veneer/BigtableHBaseVeneerSettings.java
index defc5f1b4..f186680ff 100644
--- a/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/wrappers/veneer/BigtableHBaseVeneerSettings.java
+++ b/bigtable-client-core-parent/bigtable-hbase/src/main/java/com/google/cloud/bigtable/hbase/wrappers/veneer/BigtableHBaseVeneerSettings.java
@@ -56,7 +56,6 @@ import static org.threeten.bp.Duration.ofMillis;
 import static org.threeten.bp.Duration.ofMinutes;
 import static org.threeten.bp.Duration.ofSeconds;
 
-import com.google.api.client.util.SecurityUtils;
 import com.google.api.core.ApiFunction;
 import com.google.api.core.InternalApi;
 import com.google.api.gax.batching.BatchingSettings;
@@ -89,6 +88,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.security.GeneralSecurityException;
+import java.security.KeyStore;
 import java.security.PrivateKey;
 import java.util.Collections;
 import java.util.HashSet;
@@ -399,14 +399,15 @@ public class BigtableHBaseVeneerSettings extends BigtableHBaseSettings {
 
   private Credentials buildCredentialFromPrivateKey(
       String serviceAccountEmail, String privateKeyFile) throws IOException {
+
     try {
+      KeyStore keyStore = KeyStore.getInstance("PKCS12");
+
+      try (FileInputStream fin = new FileInputStream(privateKeyFile)) {
+        keyStore.load(fin, "notasecret".toCharArray());
+      }
       PrivateKey privateKey =
-          SecurityUtils.loadPrivateKeyFromKeyStore(
-              SecurityUtils.getPkcs12KeyStore(),
-              new FileInputStream(privateKeyFile),
-              "notasecret",
-              "privatekey",
-              "notasecret");
+          (PrivateKey) keyStore.getKey("privatekey", "notasecret".toCharArray());
 
       return ServiceAccountJwtAccessCredentials.newBuilder()
           .setClientEmail(serviceAccountEmail)
diff --git a/bigtable-dataflow-parent/bigtable-beam-import/pom.xml b/bigtable-dataflow-parent/bigtable-beam-import/pom.xml
index b48ee884f..6455dfbea 100644
--- a/bigtable-dataflow-parent/bigtable-beam-import/pom.xml
+++ b/bigtable-dataflow-parent/bigtable-beam-import/pom.xml
@@ -105,7 +105,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-server</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
 
     <dependency>
@@ -213,7 +213,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-testing-util</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/bigtable-dataflow-parent/bigtable-hbase-beam/pom.xml b/bigtable-dataflow-parent/bigtable-hbase-beam/pom.xml
index ca552b7b2..728ad0c96 100755
--- a/bigtable-dataflow-parent/bigtable-hbase-beam/pom.xml
+++ b/bigtable-dataflow-parent/bigtable-hbase-beam/pom.xml
@@ -69,7 +69,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
 
     <dependency>
diff --git a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-benchmarks/pom.xml b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-benchmarks/pom.xml
index bc015417d..de4a7f827 100644
--- a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-benchmarks/pom.xml
+++ b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-benchmarks/pom.xml
@@ -41,7 +41,7 @@
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-client</artifactId>
-      <version>${hbase.version.1}</version>
+      <version>${hbase1.version}</version>
     </dependency>
     <dependency>
       <groupId>com.google.guava</groupId>
diff --git a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-hadoop/pom.xml b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-hadoop/pom.xml
index ad2dbaa1e..d0e5b778c 100644
--- a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-hadoop/pom.xml
+++ b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-hadoop/pom.xml
@@ -58,7 +58,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
 
     <!-- Manually promote dependencies: This is necessary to avoid flattening hbase-shaded-client's dependency tree -->
@@ -87,7 +87,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-common</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
 
     <dependency>
diff --git a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-mapreduce/pom.xml b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-mapreduce/pom.xml
index f8f00bc3c..806bbc6b8 100644
--- a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-mapreduce/pom.xml
+++ b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-mapreduce/pom.xml
@@ -75,17 +75,17 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-annotations</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-common</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
@@ -96,7 +96,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-server</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
   </dependencies>
 
diff --git a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-shaded/pom.xml b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-shaded/pom.xml
index e0396e477..ebdaca008 100644
--- a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-shaded/pom.xml
+++ b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-shaded/pom.xml
@@ -98,7 +98,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
 
     <dependency>
diff --git a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x/pom.xml b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x/pom.xml
index f21328cca..19ca3070a 100644
--- a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x/pom.xml
+++ b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x/pom.xml
@@ -67,7 +67,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
     </dependency>
 
     <dependency>
diff --git a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-hadoop/pom.xml b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-hadoop/pom.xml
index ad6fd229e..dfb56b4c1 100644
--- a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-hadoop/pom.xml
+++ b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-hadoop/pom.xml
@@ -30,10 +30,6 @@ limitations under the License.
     bigtable-hbase-2.x.
   </description>
 
-  <properties>
-    <hbase.version>${hbase.version.2}</hbase.version>
-  </properties>
-
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
@@ -62,7 +58,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase2.version}</version>
     </dependency>
 
     <!-- Manually promote dependencies: This is necessary to avoid flattening hbase-shaded-client's dependency tree -->
@@ -91,7 +87,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-common</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase2.version}</version>
     </dependency>
 
     <dependency>
diff --git a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-shaded/pom.xml b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-shaded/pom.xml
index 5d130b38f..8a3a1080e 100644
--- a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-shaded/pom.xml
+++ b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-shaded/pom.xml
@@ -32,10 +32,6 @@ limitations under the License.
     applications.
   </description>
 
-  <properties>
-    <hbase.version>${hbase.version.2}</hbase.version>
-  </properties>
-
   <dependencyManagement>
     <dependencies>
       <dependency>
@@ -92,7 +88,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase2.version}</version>
     </dependency>
 
     <dependency>
diff --git a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x/pom.xml b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x/pom.xml
index d2f2ef05b..05fcab77b 100644
--- a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x/pom.xml
+++ b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x/pom.xml
@@ -24,7 +24,7 @@ limitations under the License.
   </parent>
 
   <properties>
-    <hbase.version>${hbase.version.2}</hbase.version>
+    <hbase.version>${hbase2.version}</hbase.version>
   </properties>
 
   <artifactId>bigtable-hbase-2.x</artifactId>
@@ -72,7 +72,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-client</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase2.version}</version>
       <exclusions>
         <exclusion>
           <groupId>org.slf4j</groupId>
diff --git a/pom.xml b/pom.xml
index 012776d0f..f65f7ffb5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,10 +64,9 @@ limitations under the License.
     <jsr305.version>3.0.2</jsr305.version>
 
     <!-- hbase dependency versions -->
-    <hbase.version.1>1.4.12</hbase.version.1>
-    <hbase.version.2>2.2.3</hbase.version.2>
-    <hbase.version>${hbase.version.1}</hbase.version>
+    <hbase1.version>1.4.12</hbase1.version>
     <hbase1-hadoop.version>2.10.1</hbase1-hadoop.version>
+    <hbase2.version>2.2.3</hbase2.version>
     <hbase2-hadoop.version>2.8.5</hbase2-hadoop.version>
 
     <!-- testing dependency versions -->


Test patch:
diff --git a/bigtable-client-core-parent/bigtable-hbase-integration-tests-common/pom.xml b/bigtable-client-core-parent/bigtable-hbase-integration-tests-common/pom.xml
index 41e8056bf..bdd15bc92 100644
--- a/bigtable-client-core-parent/bigtable-hbase-integration-tests-common/pom.xml
+++ b/bigtable-client-core-parent/bigtable-hbase-integration-tests-common/pom.xml
@@ -33,7 +33,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-testing-util</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
       <scope>test</scope>
     </dependency>
 
diff --git a/bigtable-client-core-parent/bigtable-hbase/src/test/java/com/google/cloud/bigtable/hbase/util/TestOperationAccountant.java b/bigtable-client-core-parent/bigtable-hbase/src/test/java/com/google/cloud/bigtable/hbase/util/TestOperationAccountant.java
index 6c989d6be..a09333082 100644
--- a/bigtable-client-core-parent/bigtable-hbase/src/test/java/com/google/cloud/bigtable/hbase/util/TestOperationAccountant.java
+++ b/bigtable-client-core-parent/bigtable-hbase/src/test/java/com/google/cloud/bigtable/hbase/util/TestOperationAccountant.java
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
 
-import com.google.api.client.util.NanoClock;
+import com.google.api.core.ApiClock;
 import com.google.api.core.SettableApiFuture;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -42,7 +42,7 @@ import org.mockito.stubbing.Answer;
 public class TestOperationAccountant {
   @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule();
 
-  @Mock NanoClock clock;
+  @Mock ApiClock clock;
 
   @Test
   public void testOnOperationCompletion() {
diff --git a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-integration-tests/pom.xml b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-integration-tests/pom.xml
index 1f367cc64..902eec868 100644
--- a/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-integration-tests/pom.xml
+++ b/bigtable-hbase-1.x-parent/bigtable-hbase-1.x-integration-tests/pom.xml
@@ -383,7 +383,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-testing-util</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase1.version}</version>
       <scope>test</scope>
     </dependency>
 
diff --git a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-integration-tests/pom.xml b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-integration-tests/pom.xml
index 21c47568f..7f5636465 100644
--- a/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-integration-tests/pom.xml
+++ b/bigtable-hbase-2.x-parent/bigtable-hbase-2.x-integration-tests/pom.xml
@@ -32,7 +32,7 @@ limitations under the License.
   </description>
 
   <properties>
-    <hbase.version>${hbase.version.2}</hbase.version>
+    <hbase.version>${hbase2.version}</hbase.version>
     <google.bigtable.connection.impl>
       com.google.cloud.bigtable.hbase2_x.BigtableConnection
     </google.bigtable.connection.impl>
@@ -383,7 +383,7 @@ limitations under the License.
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-shaded-testing-util</artifactId>
-      <version>${hbase.version}</version>
+      <version>${hbase2.version}</version>
       <scope>test</scope>
     </dependency>