From 2d627aa6321f315871e71d35a70ff46cfee902f1 Mon Sep 17 00:00:00 2001 From: Astha Mohta Date: Mon, 21 Mar 2022 13:12:16 +0530 Subject: [PATCH] linting changes --- .../clirr-ignored-differences.xml | 25 +++++++++++ .../java/com/google/cloud/spanner/Backup.java | 6 +-- .../com/google/cloud/spanner/BackupInfo.java | 27 +++++++----- patch.patch | 42 ------------------- samples/pom.xml | 20 ++++++++- 5 files changed, 64 insertions(+), 56 deletions(-) delete mode 100644 patch.patch diff --git a/google-cloud-spanner/clirr-ignored-differences.xml b/google-cloud-spanner/clirr-ignored-differences.xml index 464f6e9e9f8..18805fb53c2 100644 --- a/google-cloud-spanner/clirr-ignored-differences.xml +++ b/google-cloud-spanner/clirr-ignored-differences.xml @@ -35,4 +35,29 @@ com/google/cloud/spanner/connection/ConnectionOptions com.google.cloud.spanner.Dialect getDialect() + + 7013 + com/google/cloud/spanner/BackupInfo$Builder + com.google.cloud.spanner.BackupInfo$Builder setMaxExpireTime(com.google.cloud.Timestamp) + + + 7013 + com/google/cloud/spanner/BackupInfo$Builder + com.google.cloud.spanner.BackupInfo$Builder setReferencingBackup(com.google.protobuf.ProtocolStringList) + + + 7012 + com/google/cloud/spanner/DatabaseAdminClient + com.google.api.gax.longrunning.OperationFuture copyBackup(java.lang.String, java.lang.String, java.lang.String, com.google.cloud.Timestamp) + + + 7012 + com/google/cloud/spanner/DatabaseAdminClient + com.google.api.gax.longrunning.OperationFuture copyBackup(com.google.cloud.spanner.BackupId, com.google.cloud.spanner.Backup) + + + 7012 + com/google/cloud/spanner/spi/v1/SpannerRpc + com.google.api.gax.longrunning.OperationFuture copyBackUp(com.google.cloud.spanner.BackupId, com.google.cloud.spanner.Backup) + diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java index f61158332de..c824cf2de15 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Backup.java @@ -16,6 +16,8 @@ package com.google.cloud.spanner; +import static com.google.common.base.Preconditions.checkArgument; + import com.google.api.client.util.Preconditions; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.Page; @@ -26,8 +28,6 @@ import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; -import static com.google.common.base.Preconditions.checkArgument; - /** * Represents a Cloud Spanner database backup. {@code Backup} adds a layer of service related * functionality over {@code BackupInfo}. @@ -177,7 +177,7 @@ static Backup fromProto( checkArgument(!proto.getDatabase().isEmpty(), "Missing expected 'database' field"); return new Backup.Builder(client, BackupId.of(proto.getName())) .setState(fromProtoState(proto.getState())) - .setSize(proto.getSiprotected abstract Builder setMaxExpireTime(Timestamp maxExpireTime);zeBytes()) + .setSize(proto.getSizeBytes()) .setExpireTime(Timestamp.fromProto(proto.getExpireTime())) .setVersionTime(Timestamp.fromProto(proto.getVersionTime())) .setDatabase(DatabaseId.of(proto.getDatabase())) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java index 1e2edcaa1a8..a8b19973c94 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BackupInfo.java @@ -22,9 +22,8 @@ import com.google.cloud.spanner.encryption.EncryptionInfo; import com.google.protobuf.ProtocolStringList; import com.google.spanner.admin.database.v1.Database; - -import javax.annotation.Nullable; import java.util.Objects; +import javax.annotation.Nullable; /** Represents a Cloud Spanner database backup. */ public class BackupInfo { @@ -90,16 +89,14 @@ public abstract static class Builder { /** * Output Only. * - *

Returns the max allowed expiration time of the backup, with - * microseconds granularity. + *

Returns the max allowed expiration time of the backup, with microseconds granularity. */ protected abstract Builder setMaxExpireTime(Timestamp maxExpireTime); /** * Output Only. * - *

Returns the names of the destination backups being created by copying - * this source backup. + *

Returns the names of the destination backups being created by copying this source backup. */ protected abstract Builder setReferencingBackup(ProtocolStringList referencingBackup); } @@ -192,7 +189,6 @@ public Builder setMaxExpireTime(Timestamp maxExpireTime) { return this; } - @Override public Builder setReferencingBackup(ProtocolStringList referencingBackup) { this.referencingBackup = Preconditions.checkNotNull(referencingBackup); @@ -297,8 +293,10 @@ public Timestamp getMaxExpireTime() { return maxExpireTime; } - /** Returns the names of the destination backups being created by copying - * this source backup {@link Backup}. */ + /** + * Returns the names of the destination backups being created by copying this source backup {@link + * Backup}. + */ public ProtocolStringList getReferencingBackup() { return referencingBackup; } @@ -327,7 +325,16 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - id, state, size, encryptionConfig, encryptionInfo, expireTime, versionTime, database, maxExpireTime, referencingBackup); + id, + state, + size, + encryptionConfig, + encryptionInfo, + expireTime, + versionTime, + database, + maxExpireTime, + referencingBackup); } @Override diff --git a/patch.patch b/patch.patch deleted file mode 100644 index e5a1256475c..00000000000 --- a/patch.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml -index f5d1351a..9ede6f23 100644 ---- a/samples/snippets/pom.xml -+++ b/samples/snippets/pom.xml -@@ -47,6 +47,11 @@ - 6.19.1-SNAPSHOT - - -+ -+ com.google.api.grpc -+ proto-google-cloud-spanner-admin-database-v1 -+ 6.19.1-SNAPSHOT -+ - - - io.opencensus -diff --git a/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java b/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java -index 2a4db98c..c44a012d 100644 ---- a/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java -+++ b/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java -@@ -1625,9 +1625,9 @@ public class SpannerSample { - Timestamp expireTime = Timestamp.ofTimeMicroseconds(TimeUnit.MICROSECONDS.convert( - System.currentTimeMillis() + TimeUnit.DAYS.toMillis(14), TimeUnit.MILLISECONDS)); - -- // Initiate the request which returns an OperationFuture. -+ // Initiate the requefst which returns an OperationFuture. - System.out.println("Copying backup [" + backup.getId() + "]..."); -- OperationFuture op = backup.copyBackup(); -+ OperationFuture op = dbAdminClient.copyBackup(backup); - try { - // Wait for the backup operation to complete. - backup = op.get(); -@@ -1886,7 +1886,8 @@ public class SpannerSample { - TimeUnit.SECONDS.toMicros(backup.getExpireTime().getSeconds()) - + TimeUnit.NANOSECONDS.toMicros(backup.getExpireTime().getNanos()) - + TimeUnit.DAYS.toMicros(30L)); -- Timestamp newExpireTime = Math.min(expireTime, backup.getExpireTime()); -+ int timeDiff = expireTime.compareTo(backup.getExpireTime()); -+ Timestamp newExpireTime = (timeDiff < 0) ? expireTime : backup.getExpireTime(); - - System.out.println(String.format( - "Updating expire time of backup [%s] to %s...", diff --git a/samples/pom.xml b/samples/pom.xml index 8271ea6812d..53b7c5519d8 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -33,6 +33,24 @@ snippets + + + com.google.cloud + google-cloud-spanner + 6.19.1-SNAPSHOT + + + + com.google.api.grpc + grpc-google-cloud-spanner-admin-database-v1 + 6.19.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-spanner-admin-database-v1 + 6.19.1-SNAPSHOT + + @@ -53,4 +71,4 @@ - +