From 20e7c1f10a233df6d4660b31d26cd95a6d4002e9 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 23 Dec 2020 18:12:44 +0100 Subject: [PATCH 01/11] deps: update kms.version to v0.87.5 (#662) --- google-cloud-storage/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-storage/pom.xml b/google-cloud-storage/pom.xml index ec93d316ea..b4c6a22672 100644 --- a/google-cloud-storage/pom.xml +++ b/google-cloud-storage/pom.xml @@ -16,7 +16,7 @@ google-cloud-storage - 0.87.3 + 0.87.5 From f47a283db90fa7e414922e1adba8201219585964 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 29 Dec 2020 14:37:50 -0800 Subject: [PATCH 02/11] chore(java): remove formatter action Source-Author: Jeff Ching Source-Date: Tue Dec 29 10:50:17 2020 -0800 Source-Repo: googleapis/synthtool Source-Sha: 6133907dbb3ddab204a17a15d5c53ec0aae9b033 Source-Link: https://github.com/googleapis/synthtool/commit/6133907dbb3ddab204a17a15d5c53ec0aae9b033 --- .github/workflows/formatting.yaml | 25 ------------------------- synth.metadata | 5 ++--- 2 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/formatting.yaml diff --git a/.github/workflows/formatting.yaml b/.github/workflows/formatting.yaml deleted file mode 100644 index 6844407b4d..0000000000 --- a/.github/workflows/formatting.yaml +++ /dev/null @@ -1,25 +0,0 @@ -on: - pull_request_target: - types: [opened, synchronize] - branches: - - master -name: format -jobs: - format-code: - runs-on: ubuntu-latest - env: - ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} - steps: - - uses: actions/checkout@v2 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - uses: actions/setup-java@v1 - with: - java-version: 11 - - run: "mvn com.coveo:fmt-maven-plugin:format" - - uses: googleapis/code-suggester@v1 - with: - command: review - pull_number: ${{ github.event.pull_request.number }} - git_dir: '.' diff --git a/synth.metadata b/synth.metadata index c8b6f42539..744f436d5b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-storage.git", - "sha": "f03a219c5a2693e60ad8447453352246695653eb" + "sha": "20e7c1f10a233df6d4660b31d26cd95a6d4002e9" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "3f67ceece7e797a5736a25488aae35405649b90b" + "sha": "6133907dbb3ddab204a17a15d5c53ec0aae9b033" } } ], @@ -30,7 +30,6 @@ ".github/workflows/approve-readme.yaml", ".github/workflows/auto-release.yaml", ".github/workflows/ci.yaml", - ".github/workflows/formatting.yaml", ".github/workflows/samples.yaml", ".kokoro/build.bat", ".kokoro/build.sh", From 3cce1adfed18b5cfe3541c9eed05875a955f2573 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 7 Jan 2021 22:28:09 +0100 Subject: [PATCH 03/11] chore(deps): update dependency com.google.cloud:libraries-bom to v16.2.1 (#672) [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [com.google.cloud:libraries-bom](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java) | patch | `16.2.0` -> `16.2.1` | --- ### 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. --- - [ ] 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). --- samples/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 387b284f21..3fffb81b31 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 16.2.0 + 16.2.1 pom import From 9bff7f1ef53de9cfb9d63870feb5b36a5b413f2f Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 7 Jan 2021 13:42:12 -0800 Subject: [PATCH 04/11] chore: regenerate README (#673) This PR was generated using Autosynth. :rainbow:
Log from Synthtool ``` 2021-01-07 21:30:27,538 synthtool [DEBUG] > Executing /root/.cache/synthtool/java-storage/.github/readme/synth.py. On branch autosynth-readme nothing to commit, working tree clean 2021-01-07 21:30:28,433 synthtool [DEBUG] > Wrote metadata to .github/readme/synth.metadata/synth.metadata. ```
Full log will be available here: https://source.cloud.google.com/results/invocations/8bfecfb7-6067-4b72-b200-2f0857644f66/targets - [ ] To automatically regenerate this PR, check this box. --- .github/readme/synth.metadata/synth.metadata | 4 ++-- README.md | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata index a4e037790d..86b971fba1 100644 --- a/.github/readme/synth.metadata/synth.metadata +++ b/.github/readme/synth.metadata/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-storage.git", - "sha": "b91b30b152296ed79ac254726d86565741a77dd2" + "sha": "3cce1adfed18b5cfe3541c9eed05875a955f2573" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "996775eca5fd934edac3c2ae34b80ff0395b1717" + "sha": "41a4e56982620d3edcf110d76f4fcdfdec471ac8" } } ] diff --git a/README.md b/README.md index 0ee86d7aef..68e9669678 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 16.2.0 + 16.2.1 pom import @@ -43,13 +43,20 @@ If you are using Maven without BOM, add this to your dependencies: ``` -If you are using Gradle, add this to your dependencies +If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -compile 'com.google.cloud:google-cloud-storage:1.113.6' +implementation platform('com.google.cloud:libraries-bom:16.2.1') + +compile 'com.google.cloud:google-cloud-storage' +``` +If you are using Gradle without BOM, add this to your dependencies +```Groovy +compile 'com.google.cloud:google-cloud-storage:1.113.8' ``` + If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "1.113.6" +libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "1.113.8" ``` ## Authentication From 937a7dec40294795cfd472347ec419ecfc1a5cb3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 7 Jan 2021 23:16:16 +0100 Subject: [PATCH 05/11] chore(deps): update dependency com.google.cloud:google-cloud-storage to v1.113.8 (#669) [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [com.google.cloud:google-cloud-storage](https://togithub.com/googleapis/java-storage) | patch | `1.113.6` -> `1.113.8` | --- ### Release Notes
googleapis/java-storage ### [`v1.113.8`](https://togithub.com/googleapis/java-storage/blob/master/CHANGELOG.md#​11138-httpswwwgithubcomgoogleapisjava-storagecomparev11137v11138-2020-12-16) [Compare Source](https://togithub.com/googleapis/java-storage/compare/v1.113.6...v1.113.8)
--- ### 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. --- - [ ] 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). --- samples/install-without-bom/pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 401250eb43..23b2205bfb 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-storage - 1.113.6 + 1.113.8 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index d8ae9c987f..d44c7d5682 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-storage - 1.113.6 + 1.113.8 From 43ce760ea12b86b96181bce5573e209b640b9b7c Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 7 Jan 2021 22:22:07 +0000 Subject: [PATCH 06/11] chore: release 1.113.9-SNAPSHOT (#671) :robot: 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). --- google-cloud-storage/pom.xml | 4 ++-- pom.xml | 2 +- versions.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google-cloud-storage/pom.xml b/google-cloud-storage/pom.xml index b4c6a22672..2eae22109c 100644 --- a/google-cloud-storage/pom.xml +++ b/google-cloud-storage/pom.xml @@ -2,7 +2,7 @@ 4.0.0 google-cloud-storage - 1.113.8 + 1.113.9-SNAPSHOT jar Google Cloud Storage https://github.com/googleapis/java-storage @@ -12,7 +12,7 @@ com.google.cloud google-cloud-storage-parent - 1.113.8 + 1.113.9-SNAPSHOT google-cloud-storage diff --git a/pom.xml b/pom.xml index 14324e53cd..f9ac84c0d3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-storage-parent pom - 1.113.8 + 1.113.9-SNAPSHOT Storage Parent https://github.com/googleapis/java-storage diff --git a/versions.txt b/versions.txt index fbdf55cc5f..72a4de093b 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-storage:1.113.8:1.113.8 \ No newline at end of file +google-cloud-storage:1.113.8:1.113.9-SNAPSHOT \ No newline at end of file From ebb5fb29e7dc51699b1d522838f1106b42d79397 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 7 Jan 2021 14:34:08 -0800 Subject: [PATCH 07/11] chore: regenerate README (#674) This PR was generated using Autosynth. :rainbow:
Log from Synthtool ``` 2021-01-07 22:18:29,137 synthtool [DEBUG] > Executing /root/.cache/synthtool/java-storage/.github/readme/synth.py. On branch autosynth-readme nothing to commit, working tree clean 2021-01-07 22:18:29,996 synthtool [DEBUG] > Wrote metadata to .github/readme/synth.metadata/synth.metadata. ```
Full log will be available here: https://source.cloud.google.com/results/invocations/496f0266-0104-418c-b452-bc718474b7fe/targets - [ ] To automatically regenerate this PR, check this box. --- .github/readme/synth.metadata/synth.metadata | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata index 86b971fba1..00c8cf4065 100644 --- a/.github/readme/synth.metadata/synth.metadata +++ b/.github/readme/synth.metadata/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-storage.git", - "sha": "3cce1adfed18b5cfe3541c9eed05875a955f2573" + "sha": "937a7dec40294795cfd472347ec419ecfc1a5cb3" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "41a4e56982620d3edcf110d76f4fcdfdec471ac8" + "sha": "67f09bf301083798e7220137723222eb00b8f88a" } } ] diff --git a/README.md b/README.md index 68e9669678..f88020a60e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-storage - 1.113.6 + 1.113.8 ``` From 44f49e0a33c3e541d9f8b22622ffff17cc8b8eaa Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Tue, 12 Jan 2021 12:52:05 -0800 Subject: [PATCH 08/11] fix: last chunk is retriable (#677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Ensure the tests and linter pass - [x] Appropriate docs were updated (if necessary) Fixes #666 ☕️ --- .../cloud/storage/BlobWriteChannel.java | 18 +++++- .../cloud/storage/spi/v1/HttpStorageRpc.java | 2 +- .../cloud/storage/BlobWriteChannelTest.java | 58 +++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java index 2e9c0a3804..ca87933c0f 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java @@ -120,6 +120,14 @@ public void run() { // For completeness, this case is not possible because it would require retrying // a 400 status code which is not allowed. // + // Case 7: remoteNextByteOffset==-1 && last == true + // Upload is complete and retry occurred in the "last" chunk. Data sent was + // received by the service. + // + // Case 8: remoteNextByteOffset==-1 && last == false + // Upload was completed by another client because this retry did not occur + // during the last chunk. + // // Get remote offset from API long remoteNextByteOffset = getOptions().getStorageRpcV1().getCurrentUploadOffset(getUploadId()); @@ -154,7 +162,8 @@ && driftOffset < getChunkSize()) { // Continue to next chunk retrying = false; return; - } else { + } else if (localNextByteOffset < remoteNextByteOffset + && driftOffset > getChunkSize()) { // Case 5 StringBuilder sb = new StringBuilder(); sb.append( @@ -167,6 +176,13 @@ && driftOffset < getChunkSize()) { sb.append("remoteNextByteOffset: ").append(remoteNextByteOffset).append('\n'); sb.append("driftOffset: ").append(driftOffset).append("\n\n"); throw new StorageException(0, sb.toString()); + } else if (remoteNextByteOffset == -1 && last) { + // Case 7 + retrying = false; + return; + } else if (remoteNextByteOffset == -1 && !last) { + // Case 8 + throw new StorageException(0, "Resumable upload is already complete."); } } // Request was successful and retrying state is now disabled. diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java index abdfa33ca6..37aff2739a 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java @@ -766,7 +766,7 @@ public long getCurrentUploadOffset(String uploadId) { response = httpRequest.execute(); int code = response.getStatusCode(); if (code == 201 || code == 200) { - throw new StorageException(0, "Resumable upload is already complete."); + return -1; } StringBuilder sb = new StringBuilder(); sb.append("Not sure what occurred. Here's debugging information:\n"); diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java index b6d7bbf3a3..eefee77290 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java @@ -202,6 +202,64 @@ public void testWriteWithFlushRetryChunkWithDrift() throws IOException { assertArrayEquals(buffer.array(), capturedBuffer.getValue()); } + @Test + public void testWriteWithLastFlushRetryChunkButCompleted() throws IOException { + StorageException exception = new StorageException(new SocketException("Socket closed")); + ByteBuffer buffer = randomBuffer(MIN_CHUNK_SIZE); + Capture capturedBuffer = Capture.newInstance(); + expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID); + expect( + storageRpcMock.writeWithResponse( + eq(UPLOAD_ID), + capture(capturedBuffer), + eq(0), + eq(0L), + eq(MIN_CHUNK_SIZE), + eq(true))) + .andThrow(exception); + expect(storageRpcMock.getCurrentUploadOffset(eq(UPLOAD_ID))).andReturn(-1L); + replay(storageRpcMock); + writer = new BlobWriteChannel(options, BLOB_INFO, EMPTY_RPC_OPTIONS); + assertEquals(MIN_CHUNK_SIZE, writer.write(buffer)); + writer.close(); + assertFalse(writer.isRetrying()); + assertFalse(writer.isOpen()); + // Capture captures entire buffer of a chunk even when not completely used. + // Making assert selective up to the size of MIN_CHUNK_SIZE + assertArrayEquals(Arrays.copyOf(capturedBuffer.getValue(), MIN_CHUNK_SIZE), buffer.array()); + } + + @Test + public void testWriteWithFlushRetryChunkButCompletedByAnotherClient() throws IOException { + StorageException exception = new StorageException(new SocketException("Socket closed")); + StorageException completedException = + new StorageException(0, "Resumable upload is already complete."); + ByteBuffer buffer = randomBuffer(MIN_CHUNK_SIZE); + Capture capturedBuffer = Capture.newInstance(); + expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID); + expect( + storageRpcMock.writeWithResponse( + eq(UPLOAD_ID), + capture(capturedBuffer), + eq(0), + eq(0L), + eq(MIN_CHUNK_SIZE), + eq(false))) + .andThrow(exception); + expect(storageRpcMock.getCurrentUploadOffset(eq(UPLOAD_ID))).andReturn(-1L); + replay(storageRpcMock); + writer = new BlobWriteChannel(options, BLOB_INFO, EMPTY_RPC_OPTIONS); + writer.setChunkSize(MIN_CHUNK_SIZE); + try { + writer.write(buffer); + fail("Expected completed exception."); + } catch (StorageException ex) { + assertEquals(ex, completedException); + } + assertTrue(writer.isRetrying()); + assertTrue(writer.isOpen()); + } + @Test public void testWriteWithFlush() throws IOException { expect(storageRpcMock.open(BLOB_INFO.toPb(), EMPTY_RPC_OPTIONS)).andReturn(UPLOAD_ID); From d4a237f4dff9dd870a69d5da9d690c14d4e88610 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 12 Jan 2021 22:22:27 +0100 Subject: [PATCH 09/11] deps: update dependency com.google.cloud:google-cloud-shared-dependencies to v0.17.1 (#678) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f9ac84c0d3..51864ccfd0 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ UTF-8 github google-cloud-storage-parent - 0.17.0 + 0.17.1
From d31a39b88b2d8adb04549330f9b8ff1c1a516b69 Mon Sep 17 00:00:00 2001 From: JesseLovelace <43148100+JesseLovelace@users.noreply.github.com> Date: Tue, 12 Jan 2021 14:01:12 -0800 Subject: [PATCH 10/11] fix: unnecessary options in resumable upload URL (#679) * Fix unnecessary options in resumable upload URL * Fix format and streamline --- .../cloud/storage/spi/v1/HttpStorageRpc.java | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java index 37aff2739a..74977dc6ec 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java @@ -888,38 +888,30 @@ public String open(StorageObject object, Map options) { if (kmsKeyName != null && kmsKeyName.contains("cryptoKeyVersions")) { object.setKmsKeyName(""); } - Insert req = storage.objects().insert(object.getBucket(), object); - GenericUrl url = req.buildHttpRequest().getUrl(); - String scheme = url.getScheme(); - String host = url.getHost(); - int port = url.getPort(); - port = port > 0 ? port : url.toURL().getDefaultPort(); - String path = "/upload" + url.getRawPath(); - url = new GenericUrl(scheme + "://" + host + ":" + port + path); + Insert req = + storage + .objects() + .insert(object.getBucket(), object) + .setName(object.getName()) + .setProjection(Option.PROJECTION.getString(options)) + .setPredefinedAcl(Option.PREDEFINED_ACL.getString(options)) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) + .setUserProject(Option.USER_PROJECT.getString(options)) + .setKmsKeyName(Option.KMS_KEY_NAME.getString(options)); + GenericUrl url = req.buildHttpRequestUrl(); + url.setRawPath("/upload" + url.getRawPath()); url.set("uploadType", "resumable"); - url.set("name", object.getName()); - for (Option option : options.keySet()) { - Object content = option.get(options); - if (content != null) { - url.set(option.value(), content.toString()); - } - } + JsonFactory jsonFactory = storage.getJsonFactory(); HttpRequestFactory requestFactory = storage.getRequestFactory(); HttpRequest httpRequest = requestFactory.buildPostRequest(url, new JsonHttpContent(jsonFactory, object)); HttpHeaders requestHeaders = httpRequest.getHeaders(); requestHeaders.set("X-Upload-Content-Type", detectContentType(object, options)); - String key = Option.CUSTOMER_SUPPLIED_KEY.getString(options); - if (key != null) { - BaseEncoding base64 = BaseEncoding.base64(); - HashFunction hashFunction = Hashing.sha256(); - requestHeaders.set("x-goog-encryption-algorithm", "AES256"); - requestHeaders.set("x-goog-encryption-key", key); - requestHeaders.set( - "x-goog-encryption-key-sha256", - base64.encode(hashFunction.hashBytes(base64.decode(key)).asBytes())); - } + setEncryptionHeaders(requestHeaders, "x-goog-encryption-", options); HttpResponse response = httpRequest.execute(); if (response.getStatusCode() != 200) { GoogleJsonError error = new GoogleJsonError(); From 504c22b37d5d0663a1738ebbb0876eb2360fcdb7 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 12 Jan 2021 16:09:48 -0800 Subject: [PATCH 11/11] chore: release 1.113.9 (#675) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 14 ++++++++++++++ google-cloud-storage/pom.xml | 4 ++-- pom.xml | 2 +- versions.txt | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dd7801d64..091acfc360 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +### [1.113.9](https://www.github.com/googleapis/java-storage/compare/v1.113.8...v1.113.9) (2021-01-12) + + +### Bug Fixes + +* last chunk is retriable ([#677](https://www.github.com/googleapis/java-storage/issues/677)) ([44f49e0](https://www.github.com/googleapis/java-storage/commit/44f49e0a33c3e541d9f8b22622ffff17cc8b8eaa)) +* unnecessary options in resumable upload URL ([#679](https://www.github.com/googleapis/java-storage/issues/679)) ([d31a39b](https://www.github.com/googleapis/java-storage/commit/d31a39b88b2d8adb04549330f9b8ff1c1a516b69)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.17.1 ([#678](https://www.github.com/googleapis/java-storage/issues/678)) ([d4a237f](https://www.github.com/googleapis/java-storage/commit/d4a237f4dff9dd870a69d5da9d690c14d4e88610)) +* update kms.version to v0.87.5 ([#662](https://www.github.com/googleapis/java-storage/issues/662)) ([20e7c1f](https://www.github.com/googleapis/java-storage/commit/20e7c1f10a233df6d4660b31d26cd95a6d4002e9)) + ### [1.113.8](https://www.github.com/googleapis/java-storage/compare/v1.113.7...v1.113.8) (2020-12-16) diff --git a/google-cloud-storage/pom.xml b/google-cloud-storage/pom.xml index 2eae22109c..89ebf31040 100644 --- a/google-cloud-storage/pom.xml +++ b/google-cloud-storage/pom.xml @@ -2,7 +2,7 @@ 4.0.0 google-cloud-storage - 1.113.9-SNAPSHOT + 1.113.9 jar Google Cloud Storage https://github.com/googleapis/java-storage @@ -12,7 +12,7 @@ com.google.cloud google-cloud-storage-parent - 1.113.9-SNAPSHOT + 1.113.9 google-cloud-storage diff --git a/pom.xml b/pom.xml index 51864ccfd0..67c815dbba 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-storage-parent pom - 1.113.9-SNAPSHOT + 1.113.9 Storage Parent https://github.com/googleapis/java-storage diff --git a/versions.txt b/versions.txt index 72a4de093b..c9e7c73029 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-storage:1.113.8:1.113.9-SNAPSHOT \ No newline at end of file +google-cloud-storage:1.113.9:1.113.9 \ No newline at end of file