Repository: googleapis/java-storage
Pull request #189 (2020-03-16 21:13:15)

deps: update dependency com.google.apis:google-api-services-storage to v1-rev20200226-1.30.9
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| com.google.apis:google-api-services-storage | patch | `v1-rev20191127-1.30.9` -> `v1-rev20200226-1.30.9` |

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/java-storage).

codecov[bot]: # [Codecov](https://codecov.io/gh/googleapis/java-storage/pull/189?src=pr&el=h1) Report
> Merging [#189](https://codecov.io/gh/googleapis/java-storage/pull/189?src=pr&el=desc) into [master](https://codecov.io/gh/googleapis/java-storage/commit/37958253821fe9d32270d34d736a68a3a3915629?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/googleapis/java-storage/pull/189/graphs/tree.svg?width=650&token=ssm139YOdp&height=150&src=pr)](https://codecov.io/gh/googleapis/java-storage/pull/189?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master     #189   +/-   ##
=========================================
  Coverage     63.62%   63.62%           
  Complexity      546      546           
=========================================
  Files            30       30           
  Lines          4778     4778           
  Branches        429      429           
=========================================
  Hits           3040     3040           
  Misses         1577     1577           
  Partials        161      161
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/googleapis/java-storage/pull/189?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/googleapis/java-storage/pull/189?src=pr&el=footer). Last update [3795825...129d986](https://codecov.io/gh/googleapis/java-storage/pull/189?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageException.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageException.java
index 1f740194..f4b8d0c4 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageException.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageException.java
@@ -35,7 +35,6 @@ import java.util.Set;
 public final class StorageException extends BaseHttpServiceException {
   private static final String INTERNAL_ERROR = "internalError";
   private static final String CONNECTION_CLOSED_PREMATURELY = "connectionClosedPrematurely";
-  private static final String CONNECTION_RESET = "connectionReset";
 
   // see: https://cloud.google.com/storage/docs/resumable-uploads-xml#practices
   private static final Set<Error> RETRYABLE_ERRORS =
@@ -47,8 +46,7 @@ public final class StorageException extends BaseHttpServiceException {
           new Error(429, null),
           new Error(408, null),
           new Error(null, INTERNAL_ERROR),
-          new Error(null, CONNECTION_CLOSED_PREMATURELY),
-          new Error(null, CONNECTION_RESET));
+          new Error(null, CONNECTION_CLOSED_PREMATURELY));
 
   private static final long serialVersionUID = -4168430271327813063L;
 
@@ -86,7 +84,7 @@ public final class StorageException extends BaseHttpServiceException {
   /**
    * Translate IOException to a StorageException representing the cause of the error. This method
    * defaults to idempotent always being {@code true}. Additionally, this method translates
-   * transient issues Connection Closed Prematurely and Connection Reset as retryable errors.
+   * transient issues Connection Closed Prematurely as a retryable error.
    *
    * @returns {@code StorageException}
    */
@@ -94,8 +92,6 @@ public final class StorageException extends BaseHttpServiceException {
     if (exception.getMessage().contains("Connection closed prematurely")) {
       return new StorageException(
           0, exception.getMessage(), CONNECTION_CLOSED_PREMATURELY, exception);
-    } else if (exception.getMessage().contains("Connection reset")) {
-      return new StorageException(0, exception.getMessage(), CONNECTION_RESET, exception);
     } else {
       // default
       return new StorageException(exception);
diff --git a/pom.xml b/pom.xml
index fe80a8a9..69e89e4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,7 @@
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <github.global.server>github</github.global.server>
     <site.installationModule>google-cloud-storage-parent</site.installationModule>
-    <google.core.version>1.93.2</google.core.version>
+    <google.core.version>1.93.3</google.core.version>
     <google.api-common.version>1.8.1</google.api-common.version>
     <junit.version>4.13</junit.version>
     <threeten.version>1.4.1</threeten.version>
@@ -124,7 +124,7 @@
       <dependency>
         <groupId>com.google.apis</groupId>
         <artifactId>google-api-services-storage</artifactId>
-        <version>v1-rev20191127-1.30.9</version>
+        <version>v1-rev20200226-1.30.9</version>
       </dependency>
       <dependency>
         <groupId>org.checkerframework</groupId>


Test patch:
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/testing/RemoteStorageHelper.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/testing/RemoteStorageHelper.java
index 299ac039..eb18e4a7 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/testing/RemoteStorageHelper.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/testing/RemoteStorageHelper.java
@@ -75,7 +75,9 @@ public class RemoteStorageHelper {
           @Override
           public void run() {
             Page<Bucket> buckets =
-                storage.list(Storage.BucketListOption.prefix(BUCKET_NAME_PREFIX));
+                storage.list(
+                    Storage.BucketListOption.prefix(BUCKET_NAME_PREFIX),
+                    Storage.BucketListOption.userProject(storage.getOptions().getProjectId()));
             for (Bucket bucket : buckets.iterateAll()) {
               if (bucket.getCreateTime() < olderThan) {
                 try {
@@ -88,10 +90,9 @@ public class RemoteStorageHelper {
                           .iterateAll()) {
                     if (blob.getEventBasedHold() == true || blob.getTemporaryHold() == true) {
                       storage.update(
-                          blob.toBuilder()
-                              .setTemporaryHold(false)
-                              .setEventBasedHold(false)
-                              .build());
+                          blob.toBuilder().setTemporaryHold(false).setEventBasedHold(false).build(),
+                          Storage.BlobTargetOption.userProject(
+                              storage.getOptions().getProjectId()));
                     }
                   }
                   forceDelete(storage, bucket.getName());
diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageExceptionTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageExceptionTest.java
index e065f401..0051cac4 100644
--- a/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageExceptionTest.java
+++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageExceptionTest.java
@@ -141,11 +141,23 @@ public class StorageExceptionTest {
   public void testTranslateConnectionReset() {
     StorageException exception =
         StorageException.translate(
-            new IOException(
+            new SSLException(
                 "Connection has been shutdown: "
                     + new SSLException(new SocketException("Connection reset"))));
     assertEquals(0, exception.getCode());
-    assertEquals("connectionReset", exception.getReason());
+    assertTrue(exception.isRetryable());
+  }
+
+  @Test
+  public void testTranslateConnectionShutdown() {
+    StorageException exception =
+        StorageException.translate(
+            new SSLException(
+                "Connection has been shutdown: "
+                    + new SSLException(new SocketException("Socket closed"))));
+    String test = exception.getMessage();
+
+    assertEquals(0, exception.getCode());
     assertTrue(exception.isRetryable());
   }
 
diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
index 31dc630f..dd47e744 100644
--- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
+++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
@@ -126,6 +126,7 @@ import javax.crypto.spec.SecretKeySpec;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -192,6 +193,23 @@ public class ITStorageTest {
     prepareKmsKeys();
   }
 
+  @Before
+  public void beforeEach() {
+    Bucket remoteBucket =
+        storage.get(
+            BUCKET,
+            Storage.BucketGetOption.fields(BucketField.ID, BucketField.BILLING),
+            Storage.BucketGetOption.userProject(storage.getOptions().getProjectId()));
+    // Disable requester pays in case a test fails to clean up.
+    if (remoteBucket.requesterPays() != null && remoteBucket.requesterPays() == true) {
+      remoteBucket
+          .toBuilder()
+          .setRequesterPays(false)
+          .build()
+          .update(Storage.BucketTargetOption.userProject(storage.getOptions().getProjectId()));
+    }
+  }
+
   @AfterClass
   public static void afterClass() throws ExecutionException, InterruptedException {
     if (storage != null) {
@@ -867,8 +885,9 @@ public class ITStorageTest {
     assertNotNull(storage.create(blob1));
 
     // Test listing a Requester Pays bucket.
-    Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID));
-    assertNull(remoteBucket.requesterPays());
+    Bucket remoteBucket =
+        storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID, BucketField.BILLING));
+    assertFalse(remoteBucket.requesterPays());
     remoteBucket = remoteBucket.toBuilder().setRequesterPays(true).build();
     Bucket updatedBucket = storage.update(remoteBucket);
     assertTrue(updatedBucket.requesterPays());
@@ -2138,7 +2157,8 @@ public class ITStorageTest {
 
   private void testBucketAclRequesterPays(boolean requesterPays) {
     if (requesterPays) {
-      Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID));
+      Bucket remoteBucket =
+          storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID, BucketField.BILLING));
       assertNull(remoteBucket.requesterPays());
       remoteBucket = remoteBucket.toBuilder().setRequesterPays(true).build();
       Bucket updatedBucket = storage.update(remoteBucket);
@@ -2164,6 +2184,18 @@ public class ITStorageTest {
     assertTrue(acls.contains(updatedAcl));
     assertTrue(storage.deleteAcl(BUCKET, User.ofAllAuthenticatedUsers(), bucketOptions));
     assertNull(storage.getAcl(BUCKET, User.ofAllAuthenticatedUsers(), bucketOptions));
+    if (requesterPays) {
+      Bucket remoteBucket =
+          storage.get(
+              BUCKET,
+              Storage.BucketGetOption.fields(BucketField.ID, BucketField.BILLING),
+              Storage.BucketGetOption.userProject(projectId));
+      assertTrue(remoteBucket.requesterPays());
+      remoteBucket = remoteBucket.toBuilder().setRequesterPays(false).build();
+      Bucket updatedBucket =
+          storage.update(remoteBucket, Storage.BucketTargetOption.userProject(projectId));
+      assertFalse(updatedBucket.requesterPays());
+    }
   }
 
   @Test
@@ -2347,8 +2379,9 @@ public class ITStorageTest {
 
   @Test
   public void testBucketPolicyV1RequesterPays() {
-    Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID));
-    assertNull(remoteBucket.requesterPays());
+    Bucket remoteBucket =
+        storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID, BucketField.BILLING));
+    assertFalse(remoteBucket.requesterPays());
     remoteBucket = remoteBucket.toBuilder().setRequesterPays(true).build();
     Bucket updatedBucket = storage.update(remoteBucket);
     assertTrue(updatedBucket.requesterPays());
@@ -2407,6 +2440,9 @@ public class ITStorageTest {
             BUCKET,
             ImmutableList.of("storage.buckets.getIamPolicy", "storage.buckets.setIamPolicy"),
             bucketOptions));
+    remoteBucket = remoteBucket.toBuilder().setRequesterPays(false).build();
+    updatedBucket = storage.update(remoteBucket, Storage.BucketTargetOption.userProject(projectId));
+    assertFalse(updatedBucket.requesterPays());
   }
 
   @Test
@@ -2624,7 +2660,8 @@ public class ITStorageTest {
 
   @Test
   public void testUpdateBucketLabel() {
-    Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID));
+    Bucket remoteBucket =
+        storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID, BucketField.BILLING));
     assertNull(remoteBucket.getLabels());
     remoteBucket = remoteBucket.toBuilder().setLabels(BUCKET_LABELS).build();
     Bucket updatedBucket = storage.update(remoteBucket);
@@ -2635,8 +2672,9 @@ public class ITStorageTest {
 
   @Test
   public void testUpdateBucketRequesterPays() {
-    Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID));
-    assertNull(remoteBucket.requesterPays());
+    Bucket remoteBucket =
+        storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID, BucketField.BILLING));
+    assertFalse(remoteBucket.requesterPays());
     remoteBucket = remoteBucket.toBuilder().setRequesterPays(true).build();
     Bucket updatedBucket = storage.update(remoteBucket);
     assertTrue(updatedBucket.requesterPays());
@@ -2646,8 +2684,12 @@ public class ITStorageTest {
     String blobName = "test-create-empty-blob-requester-pays";
     Blob remoteBlob = updatedBucket.create(blobName, BLOB_BYTE_CONTENT, option);
     assertNotNull(remoteBlob);
-    byte[] readBytes = storage.readAllBytes(BUCKET, blobName);
+    byte[] readBytes =
+        storage.readAllBytes(BUCKET, blobName, Storage.BlobSourceOption.userProject(projectId));
     assertArrayEquals(BLOB_BYTE_CONTENT, readBytes);
+    remoteBucket = remoteBucket.toBuilder().setRequesterPays(false).build();
+    updatedBucket = storage.update(remoteBucket, Storage.BucketTargetOption.userProject(projectId));
+    assertFalse(updatedBucket.requesterPays());
   }
 
   @Test
@@ -2786,6 +2828,12 @@ public class ITStorageTest {
       assertTrue(remoteBucket.retentionPolicyIsLocked());
       assertNotNull(remoteBucket.getRetentionEffectiveTime());
     } finally {
+      if (requesterPays) {
+        bucketInfo = bucketInfo.toBuilder().setRequesterPays(false).build();
+        Bucket updateBucket =
+            storage.update(bucketInfo, Storage.BucketTargetOption.userProject(projectId));
+        assertFalse(updateBucket.requesterPays());
+      }
       RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS);
     }
   }