From 1fe262d683a6a6976bbb3ab34f5fcafb1d158a7e Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Wed, 26 Jul 2023 02:52:19 +0200 Subject: [PATCH] deps: update dependency com.google.cloud:google-cloud-storage to v2.25.0 (#1215) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend 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.22.6` -> `2.25.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.cloud:google-cloud-storage/2.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.cloud:google-cloud-storage/2.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.cloud:google-cloud-storage/2.22.6/2.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.cloud:google-cloud-storage/2.22.6/2.25.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-storage (com.google.cloud:google-cloud-storage) ### [`v2.25.0`](https://togithub.com/googleapis/java-storage/blob/HEAD/CHANGELOG.md#2250-2023-07-24) [Compare Source](https://togithub.com/googleapis/java-storage/compare/v2.24.0...v2.25.0) ##### Features - BlobWriteChannelV2 - same throughput less GC ([#​2110](https://togithub.com/googleapis/java-storage/issues/2110)) ([1b52a10](https://togithub.com/googleapis/java-storage/commit/1b52a1053130620011515060787bada10c324c0b)) - Update Storage.createFrom(BlobInfo, Path) to have 150% higher throughput ([#​2059](https://togithub.com/googleapis/java-storage/issues/2059)) ([4c2f44e](https://togithub.com/googleapis/java-storage/commit/4c2f44e28a1ff19ffb2a02e3cefc062a1dd98fdc)) ##### Bug Fixes - Update BlobWriteChannelV2 to properly carry forward offset after incremental flush ([#​2125](https://togithub.com/googleapis/java-storage/issues/2125)) ([c099a2f](https://togithub.com/googleapis/java-storage/commit/c099a2f4f8ea9afa6953270876653916b021fd9f)) - Update GrpcStorageImpl.createFrom(BlobInfo, Path) to use RewindableContent ([#​2112](https://togithub.com/googleapis/java-storage/issues/2112)) ([c805051](https://togithub.com/googleapis/java-storage/commit/c80505129baa831e492a5514e937875407211595)) ##### Documentation - Fix broken link for TESTING.md ([#​2126](https://togithub.com/googleapis/java-storage/issues/2126)) ([fe9662d](https://togithub.com/googleapis/java-storage/commit/fe9662d7e552aabfc9012e582ae634f46af1f255)) ##### Dependencies - **test:** Update gcr.io/cloud-devrel-public-resources/storage-testbench docker tag to v0.37.0 ([#​2130](https://togithub.com/googleapis/java-storage/issues/2130)) ([9e8b6d3](https://togithub.com/googleapis/java-storage/commit/9e8b6d324bfef84e2c2ee93c424b2e7fcb601945)) - Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.13.1 ([#​2129](https://togithub.com/googleapis/java-storage/issues/2129)) ([a7e854e](https://togithub.com/googleapis/java-storage/commit/a7e854ecb4d7fa9508a8d0844fc08d9eeab6f653)) - Update dependency org.junit.vintage:junit-vintage-engine to v5.10.0 ([#​2132](https://togithub.com/googleapis/java-storage/issues/2132)) ([f5477e4](https://togithub.com/googleapis/java-storage/commit/f5477e4eb168dfd3151d0e2c0462e5b35eb3de37)) - Update junit-platform.version to v5.10.0 ([#​2133](https://togithub.com/googleapis/java-storage/issues/2133)) ([3d22686](https://togithub.com/googleapis/java-storage/commit/3d2268642dcecea8ca55e78479ad4e4390075814)) ### [`v2.24.0`](https://togithub.com/googleapis/java-storage/blob/HEAD/CHANGELOG.md#2240-2023-07-11) [Compare Source](https://togithub.com/googleapis/java-storage/compare/v2.23.0...v2.24.0) ##### Features - Add validation around bytes received vs bytes expected ([#​2078](https://togithub.com/googleapis/java-storage/issues/2078)) ([45d142a](https://togithub.com/googleapis/java-storage/commit/45d142a7ba45a80fca05fc9d8c8d7ce376d3f39c)) - Initial Preview of Transfer Manager [#​2105](https://togithub.com/googleapis/java-storage/issues/2105) ([8b17574](https://togithub.com/googleapis/java-storage/commit/8b175745d306e3da58ec3c9307442f14a34fd4ef)) ##### Bug Fixes - Update grpc upload logic to follow hashing behavior of json ([#​2107](https://togithub.com/googleapis/java-storage/issues/2107)) ([ed05232](https://togithub.com/googleapis/java-storage/commit/ed05232889c0442f43eacde5dbc80f44f09ebe83)) - Update UploadCallable to use createFrom to avoid NPE trying to resolve resulting object ([#​2086](https://togithub.com/googleapis/java-storage/issues/2086)) ([6769a2b](https://togithub.com/googleapis/java-storage/commit/6769a2b3b06fb297ebce819fbdfba5ee377be147)) ##### Documentation - Javadocs for remainder of Transfer Manager ([#​2097](https://togithub.com/googleapis/java-storage/issues/2097)) ([0362e80](https://togithub.com/googleapis/java-storage/commit/0362e80386d8055811082204536f596ba948a963)) - Javadocs for TransferManager interface and ParallelUploadConfig ([#​2094](https://togithub.com/googleapis/java-storage/issues/2094)) ([63d8ed3](https://togithub.com/googleapis/java-storage/commit/63d8ed37a80304e57b3f48aae614af89a9543ffa)) - **samples:** Add storage_grpc_quickstart samples ([#​2041](https://togithub.com/googleapis/java-storage/issues/2041)) ([5f916fb](https://togithub.com/googleapis/java-storage/commit/5f916fbba789edd33c2b4195db885d2b0191f860)) ##### Dependencies - Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.12.0 ([#​2088](https://togithub.com/googleapis/java-storage/issues/2088)) ([18adb5a](https://togithub.com/googleapis/java-storage/commit/18adb5a18fc37eb3bb3553fe20648d68a53f987a)) - Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.13.0 ([#​2106](https://togithub.com/googleapis/java-storage/issues/2106)) ([734dee0](https://togithub.com/googleapis/java-storage/commit/734dee0402fc16a3cc8d842eb135cc5743586e35)) - Update dependency io.grpc:grpc-bom to v1.56.1 ([#​2101](https://togithub.com/googleapis/java-storage/issues/2101)) ([3102941](https://togithub.com/googleapis/java-storage/commit/31029414d8e758c01faaab398a701afebf5e934d)) - Update dependency net.jqwik:jqwik to v1.7.4 ([#​2103](https://togithub.com/googleapis/java-storage/issues/2103)) ([c681ccf](https://togithub.com/googleapis/java-storage/commit/c681ccfffe6b861c19b92e496363146adc7d862b)) - Update gcr.io/cloud-devrel-public-resources/storage-testbench docker tag to v0.36.0 ([#​2080](https://togithub.com/googleapis/java-storage/issues/2080)) ([ba5c11a](https://togithub.com/googleapis/java-storage/commit/ba5c11a1589d1c7ffefd15e921da914289bc219e)) ### [`v2.23.0`](https://togithub.com/googleapis/java-storage/blob/HEAD/CHANGELOG.md#2230-2023-06-21) [Compare Source](https://togithub.com/googleapis/java-storage/compare/v2.22.6...v2.23.0) ##### Features - Add new dedup utility method to Option classes ([#​2063](https://togithub.com/googleapis/java-storage/issues/2063)) ([2ad196c](https://togithub.com/googleapis/java-storage/commit/2ad196c063e67c7efdac344792b67de3479d789d)) ##### Dependencies - Update dependencies io.grpc:\* to v1.56.0 ([#​2072](https://togithub.com/googleapis/java-storage/issues/2072)) ([e10bde2](https://togithub.com/googleapis/java-storage/commit/e10bde26416bcf17401516e43949e12246f4831c)) - Update dependency com.google.apis:google-api-services-storage to v1-rev20230617-2.0.0 ([#​2077](https://togithub.com/googleapis/java-storage/issues/2077)) ([9f618cd](https://togithub.com/googleapis/java-storage/commit/9f618cddbeb471f7bd0f2332c70e501afbaccc36)) - Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.23 ([#​2074](https://togithub.com/googleapis/java-storage/issues/2074)) ([427f330](https://togithub.com/googleapis/java-storage/commit/427f330793a20b0c3da4cbe5e85984a0df508c79))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - 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. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/java-storage-nio). --- .../contrib/nio/testing/FakeStorageRpc.java | 71 ++++++++++++++++--- pom.xml | 2 +- 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java index 3d8367e0c2..c772a56b31 100644 --- a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java +++ b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java @@ -21,6 +21,7 @@ import com.google.api.client.http.LowLevelHttpRequest; import com.google.api.client.http.LowLevelHttpResponse; import com.google.api.client.json.gson.GsonFactory; +import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpRequest; import com.google.api.client.testing.http.MockLowLevelHttpResponse; import com.google.api.client.util.DateTime; @@ -34,12 +35,14 @@ import com.google.cloud.storage.testing.StorageRpcTestBase; import com.google.common.base.Preconditions; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.net.URLDecoder; +import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.FileAlreadyExistsException; import java.text.SimpleDateFormat; @@ -48,6 +51,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -547,13 +551,13 @@ public com.google.api.services.storage.Storage getStorage() { } private static String fullname(String bucket, String object) { - return String.format("%s/%s", bucket, object); + return String.format("http://localhost:65555/b/%s/o/%s", bucket, object); } private static final String KEY_PATTERN_DEFINITION = "^.*?/b/(.*?)/o/(.*?)(?:[?].*|$)"; private static final Pattern KEY_PATTERN = Pattern.compile(KEY_PATTERN_DEFINITION); - MyMockLowLevelHttpRequest create(String url) { + MyMockLowLevelHttpRequest create(String method, String url) { Matcher m = KEY_PATTERN.matcher(url); Preconditions.checkArgument( m.matches(), @@ -566,7 +570,7 @@ MyMockLowLevelHttpRequest create(String url) { String decode = urlDecode(object); String key = fullname(bucket, decode); - return new MyMockLowLevelHttpRequest(url, key); + return new MyMockLowLevelHttpRequest(method, url, key); } private static String urlDecode(String object) { @@ -579,10 +583,12 @@ private static String urlDecode(String object) { private class MyMockLowLevelHttpRequest extends MockLowLevelHttpRequest { + private final String method; private final String key; - private MyMockLowLevelHttpRequest(String url, String key) { + private MyMockLowLevelHttpRequest(String method, String url, String key) { super(url); + this.method = method; this.key = key; } @@ -600,8 +606,46 @@ public MockLowLevelHttpResponse getResponse() { MockLowLevelHttpResponse resp = new MockLowLevelHttpResponse(); byte[] bytes = contents.get(key); - if (bytes == null) { + StorageObject storageObject = metadata.get(key); + if (bytes == null && storageObject == null) { resp.setStatusCode(NOT_FOUND); + } else if (storageObject != null && method.equals("PUT")) { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + this.getStreamingContent().writeTo(baos); + byte[] byteArray = baos.toByteArray(); + if (storageObject.getGeneration() != null) { + contents.put(key, concat(bytes, byteArray)); + } else { + contents.put(key, byteArray); + } + + List contentRanges = getHeaders().get("content-range"); + if (contentRanges != null && !contentRanges.isEmpty()) { + String contentRange = contentRanges.get(0); + // finalization PUT + // Pattern matches both froms of begin-end/size, */size + Pattern pattern = Pattern.compile("bytes (?:\\d+-\\d+|\\*)/(\\d+)"); + Matcher matcher = pattern.matcher(contentRange); + if (matcher.matches()) { + storageObject.setSize(new BigInteger(matcher.group(1), 10)); + storageObject.setGeneration(System.currentTimeMillis()); + DateTime now = now(); + storageObject.setTimeCreated(now); + storageObject.setUpdated(now); + String string = GsonFactory.getDefaultInstance().toPrettyString(storageObject); + resp.addHeader("Content-Type", "application/json;charset=utf-8"); + resp.addHeader("Content-Length", String.valueOf(string.length())); + resp.setContent(string); + } else { + resp.setStatusCode(NOT_FOUND); + } + } else { + resp.setStatusCode(NOT_FOUND); + } + } catch (IOException e) { + throw new RuntimeException(e); + } } else { int length = bytes.length; Map> headers = getHeaders(); @@ -661,16 +705,21 @@ public MockLowLevelHttpResponse getResponse() { } } - private class FakeStorageRpcHttpTransport extends HttpTransport { + private static byte[] concat(byte[]... arrays) { + int total = Arrays.stream(arrays).filter(Objects::nonNull).mapToInt(a -> a.length).sum(); + byte[] retVal = new byte[total]; - @Override - public boolean supportsMethod(String method) { - return "GET".equals(method); - } + ByteBuffer wrap = ByteBuffer.wrap(retVal); + Arrays.stream(arrays).filter(Objects::nonNull).forEach(wrap::put); + + return retVal; + } + + private class FakeStorageRpcHttpTransport extends MockHttpTransport { @Override public LowLevelHttpRequest buildRequest(String method, String url) { - return create(url); + return create(method, url); } } } diff --git a/pom.xml b/pom.xml index daa43bea07..405cc3d929 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ com.google.cloud google-cloud-storage - 2.22.6 + 2.25.0 com.google.apis