Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: googleapis/java-storage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.6
Choose a base ref
...
head repository: googleapis/java-storage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.1.7
Choose a head ref
  • 15 commits
  • 44 files changed
  • 5 contributors

Commits on Sep 24, 2021

  1. chore: release 2.1.7-SNAPSHOT (#1044)

    🤖 I have created a release \*beep\* \*boop\*
    ---
    ### Updating meta-information for bleeding-edge SNAPSHOT release.
    ---
    
    
    This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
    release-please[bot] authored Sep 24, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c62fcb7 View commit details

Commits on Sep 27, 2021

  1. chore(retry): introduce RetryAlgorithmManager (#1029)

    ### Summary
    * RetryAlgorithmManager provides an abstraction point for determining
      which ExceptionHandler should be used for a specific call.
    * Implement LegacyRetryAlgorithmManager for which all methods return
      BaseService.EXCEPTION_HANDLER which is hardcoded everywhere
      previously.
    * Stub out NewRetryAlgorithmManager which currently extends
      LegacyRetryAlgorithmManager, but allows for overriding individual
      methods in an incremental manner.
    
    ### Refactoring
    * All usages of BaseService.EXCEPTION_HANDLER in StorageImpl, Blob,
      Bucket etc now instead use RetryAlgorithmManager to resolve a
      handler per method.
    * Refactor Blob to use Retrying#run instead of runWithRetries
    * Split starting of a resumable upload session out of BlobWriteChannel
      to ResumableMedia. This decouple the ability to instantiate a
      BlobWriteChannel independent of performing an RPC to resolve the
      uploadId. This split is also necessary to allow differing configuration
      of ExceptionHandler for open vs write of a resumable upload session.
    * Refactor StorageException#translateAndThrow to allow for an option which
      doesn't throw, new StorageException#coalesce which attempts to coalesce
      to a BaseServiceException but doesn't throw.
    * Relax several easymock assertions on StorageOptions method. (Calling get
      on an immutable object shouldn't be so concerned with invocation count)
    
    Related to #1024
    BenWhitehead authored Sep 27, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ea1eeb9 View commit details
  2. chore(deps): update dependency com.google.cloud:google-cloud-storage …

    …to v2.1.6 (#1045)
    
    [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
    
    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [com.google.cloud:google-cloud-storage](https://togithub.com/googleapis/java-storage) | `2.1.5` -> `2.1.6` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.1.6/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.1.6/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.1.6/compatibility-slim/2.1.5)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.1.6/confidence-slim/2.1.5)](https://docs.renovatebot.com/merge-confidence/) |
    
    ---
    
    ### Release Notes
    
    <details>
    <summary>googleapis/java-storage</summary>
    
    ### [`v2.1.6`](https://togithub.com/googleapis/java-storage/blob/master/CHANGELOG.md#&#8203;216-httpswwwgithubcomgoogleapisjava-storagecomparev215v216-2021-09-24)
    
    [Compare Source](https://togithub.com/googleapis/java-storage/compare/v2.1.5...v2.1.6)
    
    </details>
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: At any time (no schedule defined).
    
    🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
    
    🔕 **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#github/googleapis/java-storage).
    renovate-bot authored Sep 27, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2e7f041 View commit details

Commits on Sep 28, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6d73e46 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2c79005 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    980dbd0 View commit details
  4. test: retry conformance tests fixes, round 3 (#1050)

    * add applicability predicate for setIamPolicy mappings
    * add metageneration precondition mapping for setIamPolicy
    * add applicability predicate for hmacKey.update mappings
    * fix objects.delete mappings to use stateful blob
    * fix objects.delete to use generationMatch
    * add applicability predicate for objects.patch mappings
    BenWhitehead authored Sep 28, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3716105 View commit details

Commits on Sep 29, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7a1a928 View commit details
  2. chore: refactor PostPolicyV4Test to be compatible with behavior chang…

    …e of Collections.unmodifiableMap from jdk 17 (#1016)
    BenWhitehead authored Sep 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    575cf12 View commit details
  3. build: add jdk 17 to java units and dependency builds (#1048)

    * chore(java): rename master branch to main
    
    Source-Author: Neenu Shaji <Neenu1995@users.noreply.github.com>
    Source-Date: Mon Sep 27 10:04:11 2021 -0400
    Source-Repo: googleapis/synthtool
    Source-Sha: 67ab4f9f4272ad13f4b809de47fd0dec05f425ad
    Source-Link: googleapis/synthtool@67ab4f9
    
    * build: add jdk 17 to java units and dependency builds
    
    * update dependencies.sh to not pass MaxPermSize when jdk 17 is used. MaxPermSize is an unrecognized flag in jdk 17.
    
    Source-Author: BenWhitehead <BenWhitehead@users.noreply.github.com>
    Source-Date: Mon Sep 27 11:34:46 2021 -0400
    Source-Repo: googleapis/synthtool
    Source-Sha: a4be3384ccb92364795d981f2863f6986fcee620
    Source-Link: googleapis/synthtool@a4be338
    yoshi-automation authored Sep 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8717cd6 View commit details

Commits on Oct 1, 2021

  1. chore(retry): implement new retry exception handlers (#1058)

    * add idempotent handler
    * add idempotent resumable write handler
    * add non-idempotent handler
    
    test count summary shift after this change
    failure -> success: 55
      error -> success: 24
    success -> failure: 26
    BenWhitehead authored Oct 1, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    35cb2f7 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    97b1a2e View commit details
  3. chore(deps): update dependency com.google.cloud:libraries-bom to v23.…

    …1.0 (#1060)
    
    [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
    
    This PR contains the following updates:
    
    | Package | Change | Age | Adoption | Passing | Confidence |
    |---|---|---|---|---|---|
    | [com.google.cloud:libraries-bom](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java) | `23.0.0` -> `23.1.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/23.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/23.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/23.1.0/compatibility-slim/23.0.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/23.1.0/confidence-slim/23.0.0)](https://docs.renovatebot.com/merge-confidence/) |
    
    ---
    
    ### Configuration
    
    📅 **Schedule**: At any time (no schedule defined).
    
    🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
    
    ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
    
    🔕 **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#github/googleapis/java-storage).
    renovate-bot authored Oct 1, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    193a30a View commit details

Commits on Oct 4, 2021

  1. test(retry): fix objects.compose tests (#1062)

    * fix incorrect evaluation of idempotency for objects.compose (now generation, previously metageneration)
    * add mapping for non-idempotent objects.compose invocation
    * add CtxFunction to construct a ComposeRequest relative to the state
    * add ComposeRequest handling to state
    BenWhitehead authored Oct 4, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4478b9d View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bf3207b View commit details
Showing with 1,910 additions and 551 deletions.
  1. +1 −1 .github/blunderbuss.yml
  2. +1 −1 .github/sync-repo-settings.yaml
  3. +13 −8 .github/workflows/ci.yaml
  4. +22 −1 .kokoro/dependencies.sh
  5. +13 −0 CHANGELOG.md
  6. +13 −13 README.md
  7. +2 −2 gapic-google-cloud-storage-v2/pom.xml
  8. +3 −3 google-cloud-storage/pom.xml
  9. +15 −33 google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java
  10. +13 −14 google-cloud-storage/src/main/java/com/google/cloud/storage/BlobReadChannel.java
  11. +75 −81 google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java
  12. +18 −8 google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
  13. +2 −0 google-cloud-storage/src/main/java/com/google/cloud/storage/CopyWriter.java
  14. +242 −0 google-cloud-storage/src/main/java/com/google/cloud/storage/LegacyRetryAlgorithmManager.java
  15. +356 −0 google-cloud-storage/src/main/java/com/google/cloud/storage/NewRetryAlgorithmManager.java
  16. +73 −0 google-cloud-storage/src/main/java/com/google/cloud/storage/ResumableMedia.java
  17. +116 −0 google-cloud-storage/src/main/java/com/google/cloud/storage/RetryAlgorithmManager.java
  18. +11 −9 google-cloud-storage/src/main/java/com/google/cloud/storage/Retrying.java
  19. +20 −1 google-cloud-storage/src/main/java/com/google/cloud/storage/StorageException.java
  20. +209 −57 google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java
  21. +32 −3 google-cloud-storage/src/main/java/com/google/cloud/storage/StorageOptions.java
  22. +58 −51 google-cloud-storage/src/test/java/com/google/cloud/storage/BlobTest.java
  23. +88 −73 google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java
  24. +47 −43 google-cloud-storage/src/test/java/com/google/cloud/storage/BucketTest.java
  25. +4 −0 google-cloud-storage/src/test/java/com/google/cloud/storage/PackagePrivateMethodWorkarounds.java
  26. +4 −6 google-cloud-storage/src/test/java/com/google/cloud/storage/PostPolicyV4Test.java
  27. +66 −0 google-cloud-storage/src/test/java/com/google/cloud/storage/ResumableMediaTest.java
  28. +7 −1 google-cloud-storage/src/test/java/com/google/cloud/storage/SerializationTest.java
  29. +15 −4 google-cloud-storage/src/test/java/com/google/cloud/storage/StorageBatchTest.java
  30. +0 −12 google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java
  31. +29 −1 google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/CtxFunctions.java
  32. +2 −0 google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RetryTestFixture.java
  33. +85 −79 google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java
  34. +14 −0 google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/State.java
  35. +2 −2 google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
  36. +221 −26 ...age/src/test/resources/com/google/cloud/storage/conformance/retry/testNamesWhichShouldSucceed.txt
  37. +2 −2 grpc-google-cloud-storage-v2/pom.xml
  38. +5 −5 pom.xml
  39. +2 −2 proto-google-cloud-storage-v2/pom.xml
  40. +1 −1 samples/install-without-bom/pom.xml
  41. +1 −1 samples/snapshot/pom.xml
  42. +1 −1 samples/snippets/pom.xml
  43. +2 −2 synth.metadata
  44. +4 −4 versions.txt
2 changes: 1 addition & 1 deletion .github/blunderbuss.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Configuration for the Blunderbuss GitHub app. For more info see
# https://github.com/googleapis/repo-automation-bots/tree/master/packages/blunderbuss
# https://github.com/googleapis/repo-automation-bots/tree/main/packages/blunderbuss
assign_prs_by:
- labels:
- samples
2 changes: 1 addition & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ rebaseMergeAllowed: false
squashMergeAllowed: true
mergeCommitAllowed: false
branchProtectionRules:
- pattern: master
- pattern: main
isAdminEnforced: true
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
21 changes: 13 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
on:
push:
branches:
- master
- main
pull_request:
name: ci
jobs:
units:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11]
java: [8, 11, 17]
steps:
- uses: actions/checkout@v2
- uses: stCarolas/setup-maven@v4
with:
maven-version: 3.8.1
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: ${{matrix.java}}
- run: java -version
- run: .kokoro/build.sh
@@ -29,8 +30,9 @@ jobs:
- uses: stCarolas/setup-maven@v4
with:
maven-version: 3.8.1
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 8
- run: java -version
- run: .kokoro/build.bat
@@ -40,14 +42,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11]
java: [8, 11, 17]
steps:
- uses: actions/checkout@v2
- uses: stCarolas/setup-maven@v4
with:
maven-version: 3.8.1
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: ${{matrix.java}}
- run: java -version
- run: .kokoro/dependencies.sh
@@ -58,8 +61,9 @@ jobs:
- uses: stCarolas/setup-maven@v4
with:
maven-version: 3.8.1
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 8
- run: java -version
- run: .kokoro/build.sh
@@ -72,8 +76,9 @@ jobs:
- uses: stCarolas/setup-maven@v4
with:
maven-version: 3.8.1
- uses: actions/setup-java@v1
- uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 8
- run: java -version
- run: .kokoro/build.sh
23 changes: 22 additions & 1 deletion .kokoro/dependencies.sh
Original file line number Diff line number Diff line change
@@ -28,7 +28,28 @@ source ${scriptDir}/common.sh
java -version
echo $JOB_TYPE

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"
function determineMavenOpts() {
local javaVersion=$(
# filter down to the version line, then pull out the version between quotes,
# then trim the version number down to its minimal number (removing any
# update or suffix number).
java -version 2>&1 | grep "version" \
| sed -E 's/^.*"(.*?)".*$/\1/g' \
| sed -E 's/^(1\.[0-9]\.0).*$/\1/g'
)

case $javaVersion in
"17")
# MaxPermSize is no longer supported as of jdk 17
echo -n "-Xmx1024m"
;;
*)
echo -n "-Xmx1024m -XX:MaxPermSize=128m"
;;
esac
}

export MAVEN_OPTS=$(determineMavenOpts)

# this should run maven enforcer
retry_with_backoff 3 10 \
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

### [2.1.7](https://www.github.com/googleapis/java-storage/compare/v2.1.6...v2.1.7) (2021-10-04)


### Bug Fixes

* update PAP to use inherited instead of unspecified ([#1051](https://www.github.com/googleapis/java-storage/issues/1051)) ([6d73e46](https://www.github.com/googleapis/java-storage/commit/6d73e4631777542996a0ea815b482f5c19a8927d))


### Dependencies

* update dependency com.google.apis:google-api-services-storage to v1-rev20210918-1.32.1 ([#1046](https://www.github.com/googleapis/java-storage/issues/1046)) ([2c79005](https://www.github.com/googleapis/java-storage/commit/2c79005d29ee0b279850c7008b1afbb302f9c90d))
* update kms.version to v0.93.0 ([#1061](https://www.github.com/googleapis/java-storage/issues/1061)) ([97b1a2e](https://www.github.com/googleapis/java-storage/commit/97b1a2ebe411e48e2df095fe5518a867c5136851))

### [2.1.6](https://www.github.com/googleapis/java-storage/compare/v2.1.5...v2.1.6) (2021-09-24)


26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ Blob blob = storage.create(blobInfo, "a simple blob".getBytes(UTF_8));
```

A complete example for creating a blob can be found at
[CreateBlob.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/CreateBlob.java).
[CreateBlob.java](https://github.com/googleapis/google-cloud-java/tree/main/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/CreateBlob.java).

At this point, you will be able to see your newly created bucket and blob on the Google Developers Console.

@@ -164,7 +164,7 @@ String contentString = new String(content, UTF_8);
```

A complete example for accessing blobs can be found at
[CreateBlob.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/CreateBlob.java).
[CreateBlob.java](https://github.com/googleapis/google-cloud-java/tree/main/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/CreateBlob.java).

#### Updating data
Another thing we may want to do is update a blob. The following snippet shows how to update a Storage blob if it exists.
@@ -182,7 +182,7 @@ if (blob != null) {
```

The complete source code can be found at
[UpdateBlob.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/UpdateBlob.java).
[UpdateBlob.java](https://github.com/googleapis/google-cloud-java/tree/main/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/UpdateBlob.java).

#### Listing buckets and contents of buckets
Suppose that you've added more buckets and blobs, and now you want to see the names of your buckets and the contents
@@ -205,29 +205,29 @@ for (Bucket bucket : storage.list().iterateAll()) {
#### Complete source code

In
[CreateAndListBucketsAndBlobs.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/CreateAndListBucketsAndBlobs.java)
[CreateAndListBucketsAndBlobs.java](https://github.com/googleapis/google-cloud-java/tree/main/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/CreateAndListBucketsAndBlobs.java)
we put together examples creating and listing buckets and blobs into one program. The program assumes that you are
running on Compute Engine or from your own desktop. To run the example on App Engine, simply move
the code from the main method to your application's servlet class and change the print statements to
display on your webpage.

### Example Applications

- [`StorageExample`](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/StorageExample.java) is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the [`StorageExample` docs page](https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-examples/README.md).
- [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine application that manages a virtual bookshelf.
- [`StorageExample`](https://github.com/googleapis/google-cloud-java/tree/main/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/StorageExample.java) is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the [`StorageExample` docs page](https://github.com/googleapis/google-cloud-java/blob/main/google-cloud-examples/README.md).
- [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/main/bookshelf) - An App Engine application that manages a virtual bookshelf.
- This app uses `google-cloud` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service.
- [`Flexible Environment/Storage example`](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/flexible/cloudstorage) - An app that uploads files to a public Cloud Storage bucket on the App Engine Flexible Environment runtime.
- [`Flexible Environment/Storage example`](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/flexible/cloudstorage) - An app that uploads files to a public Cloud Storage bucket on the App Engine Flexible Environment runtime.




## Samples

Samples are in the [`samples/`](https://github.com/googleapis/java-storage/tree/master/samples) directory.
Samples are in the [`samples/`](https://github.com/googleapis/java-storage/tree/main/samples) directory.

| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Quickstart Sample | [source code](https://github.com/googleapis/java-storage/blob/master/samples/snippets/src/main/java/com/example/storage/QuickstartSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/QuickstartSample.java) |
| Quickstart Sample | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/QuickstartSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/QuickstartSample.java) |



@@ -336,10 +336,10 @@ Java is a registered trademark of Oracle and/or its affiliates.
[developer-console]: https://console.developers.google.com/
[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
[cloud-sdk]: https://cloud.google.com/sdk/
[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting
[contributing]: https://github.com/googleapis/java-storage/blob/master/CONTRIBUTING.md
[code-of-conduct]: https://github.com/googleapis/java-storage/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
[license]: https://github.com/googleapis/java-storage/blob/master/LICENSE
[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/main/troubleshooting/readme.md#troubleshooting
[contributing]: https://github.com/googleapis/java-storage/blob/main/CONTRIBUTING.md
[code-of-conduct]: https://github.com/googleapis/java-storage/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct
[license]: https://github.com/googleapis/java-storage/blob/main/LICENSE
[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing
[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=storage.googleapis.com
[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM
4 changes: 2 additions & 2 deletions gapic-google-cloud-storage-v2/pom.xml
Original file line number Diff line number Diff line change
@@ -4,13 +4,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.api.grpc</groupId>
<artifactId>gapic-google-cloud-storage-v2</artifactId>
<version>2.1.6-alpha</version><!-- {x-version-update:gapic-google-cloud-storage-v2:current} -->
<version>2.1.7-alpha</version><!-- {x-version-update:gapic-google-cloud-storage-v2:current} -->
<name>gapic-google-cloud-storage-v2</name>
<description>GRPC library for gapic-google-cloud-storage-v2</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage-parent</artifactId>
<version>2.1.6</version><!-- {x-version-update:google-cloud-storage:current} -->
<version>2.1.7</version><!-- {x-version-update:google-cloud-storage:current} -->
</parent>
<dependencies>
<dependency>
6 changes: 3 additions & 3 deletions google-cloud-storage/pom.xml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>google-cloud-storage</artifactId>
<version>2.1.6</version><!-- {x-version-update:google-cloud-storage:current} -->
<version>2.1.7</version><!-- {x-version-update:google-cloud-storage:current} -->
<packaging>jar</packaging>
<name>Google Cloud Storage</name>
<url>https://github.com/googleapis/java-storage</url>
@@ -12,11 +12,11 @@
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage-parent</artifactId>
<version>2.1.6</version><!-- {x-version-update:google-cloud-storage:current} -->
<version>2.1.7</version><!-- {x-version-update:google-cloud-storage:current} -->
</parent>
<properties>
<site.installationModule>google-cloud-storage</site.installationModule>
<kms.version>0.92.2</kms.version>
<kms.version>0.93.0</kms.version>
</properties>
<dependencies>
<dependency>
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@

package com.google.cloud.storage;

import static com.google.cloud.RetryHelper.runWithRetries;
import static com.google.cloud.storage.Blob.BlobSourceOption.toGetOptions;
import static com.google.cloud.storage.Blob.BlobSourceOption.toSourceOptions;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -25,17 +24,15 @@
import com.google.api.services.storage.model.StorageObject;
import com.google.auth.ServiceAccountSigner;
import com.google.auth.ServiceAccountSigner.SigningException;
import com.google.cloud.ExceptionHandler;
import com.google.cloud.ReadChannel;
import com.google.cloud.RetryHelper;
import com.google.cloud.Tuple;
import com.google.cloud.WriteChannel;
import com.google.cloud.storage.Acl.Entity;
import com.google.cloud.storage.Storage.BlobTargetOption;
import com.google.cloud.storage.Storage.BlobWriteOption;
import com.google.cloud.storage.Storage.CopyRequest;
import com.google.cloud.storage.Storage.SignUrlOption;
import com.google.cloud.storage.spi.v1.StorageRpc;
import com.google.common.base.Function;
import com.google.common.io.BaseEncoding;
import com.google.common.io.CountingOutputStream;
import java.io.IOException;
@@ -50,6 +47,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

/**
* An object in Google Cloud Storage. A {@code Blob} object includes the {@code BlobId} instance,
@@ -78,18 +76,9 @@ public class Blob extends BlobInfo {
private static final long serialVersionUID = -6806832496717441434L;

private final StorageOptions options;
private final RetryAlgorithmManager retryAlgorithmManager;
private transient Storage storage;

static final Function<Tuple<Storage, StorageObject>, Blob> BLOB_FROM_PB_FUNCTION =
new Function<Tuple<Storage, StorageObject>, Blob>() {
@Override
public Blob apply(Tuple<Storage, StorageObject> pb) {
return Blob.fromPb(pb.x(), pb.y());
}
};

private static final int DEFAULT_CHUNK_SIZE = 2 * 1024 * 1024;

/** Class for specifying blob source options when {@code Blob} methods are used. */
public static class BlobSourceOption extends Option {

@@ -258,26 +247,18 @@ public void downloadTo(Path path, BlobSourceOption... options) {
public void downloadTo(OutputStream outputStream, BlobSourceOption... options) {
final CountingOutputStream countingOutputStream = new CountingOutputStream(outputStream);
final StorageRpc storageRpc = this.options.getStorageRpcV1();
StorageObject pb = getBlobId().toPb();
final Map<StorageRpc.Option, ?> requestOptions = StorageImpl.optionMap(getBlobId(), options);
try {
runWithRetries(
callable(
new Runnable() {
@Override
public void run() {
storageRpc.read(
getBlobId().toPb(),
requestOptions,
countingOutputStream.getCount(),
countingOutputStream);
}
}),
this.options.getRetrySettings(),
StorageImpl.EXCEPTION_HANDLER,
this.options.getClock());
} catch (RetryHelper.RetryHelperException e) {
StorageException.translateAndThrow(e);
}
ExceptionHandler exceptionHandler = retryAlgorithmManager.getForObjectsGet(pb, requestOptions);
Retrying.run(
this.options,
exceptionHandler,
callable(
() -> {
storageRpc.read(
pb, requestOptions, countingOutputStream.getCount(), countingOutputStream);
}),
Function.identity());
}

/**
@@ -506,6 +487,7 @@ public Blob build() {
super(infoBuilder);
this.storage = checkNotNull(storage);
this.options = storage.getOptions();
this.retryAlgorithmManager = storage.getOptions().getRetryAlgorithmManager();
}

/**
Loading