-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix Storage#readAllBytes to allow reading compressed bytes (#2304)
Storage#readAllBytes currently ignores BlobSourceOption.shouldReturnRawInputStream(true), fix this so that the option is respected. Update grpc transport default compression handling for each of the following methods, so it is the same behavior as HTTP: * GrpcStorage.Impl#readAllBytes * GrpcStorage.Impl#downloadTo(BlobInfo, Path) * GrpcStorage.Impl#downloadTo(BlobInfo, OutputStream) Move the two tests from ITDownloadToTest into new ITAutomaticGzipDecompressionTest which tests compression handling for all read paths.
- Loading branch information
1 parent
d4bfcf0
commit 68b96a9
Showing
11 changed files
with
323 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
google-cloud-storage/src/test/java/com/google/cloud/storage/UtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.storage; | ||
|
||
import static com.google.cloud.storage.TestUtils.assertAll; | ||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import com.google.cloud.storage.UnifiedOpts.Opt; | ||
import com.google.cloud.storage.UnifiedOpts.Opts; | ||
import org.junit.Test; | ||
|
||
public final class UtilsTest { | ||
private static final Opts<Opt> autoGzipDecompress_undefined = Opts.empty(); | ||
private static final Opts<Opt> autoGzipDecompress_no = | ||
Opts.from(UnifiedOpts.returnRawInputStream(true)); | ||
private static final Opts<Opt> autoGzipDecompress_yes = | ||
Opts.from(UnifiedOpts.returnRawInputStream(false)); | ||
|
||
@Test | ||
public void isAutoGzipDecompression() throws Exception { | ||
assertAll( | ||
() -> | ||
assertThat( | ||
Utils.isAutoGzipDecompression( | ||
autoGzipDecompress_undefined, /*defaultWhenUndefined=*/ false)) | ||
.isFalse(), | ||
() -> | ||
assertThat( | ||
Utils.isAutoGzipDecompression( | ||
autoGzipDecompress_undefined, /*defaultWhenUndefined=*/ true)) | ||
.isTrue(), | ||
() -> | ||
assertThat( | ||
Utils.isAutoGzipDecompression( | ||
autoGzipDecompress_no, /*defaultWhenUndefined=*/ false)) | ||
.isFalse(), | ||
() -> | ||
assertThat( | ||
Utils.isAutoGzipDecompression( | ||
autoGzipDecompress_no, /*defaultWhenUndefined=*/ true)) | ||
.isFalse(), | ||
() -> | ||
assertThat( | ||
Utils.isAutoGzipDecompression( | ||
autoGzipDecompress_yes, /*defaultWhenUndefined=*/ false)) | ||
.isTrue(), | ||
() -> | ||
assertThat( | ||
Utils.isAutoGzipDecompression( | ||
autoGzipDecompress_yes, /*defaultWhenUndefined=*/ true)) | ||
.isTrue()); | ||
} | ||
} |
Oops, something went wrong.