Skip to content

Commit f925afb

Browse files
committed
address gemini review changes
1 parent 20f416c commit f925afb

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

java-storage/google-cloud-storage/src/main/java/com/google/cloud/storage/ApiaryUnbufferedReadableByteChannel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
143143
Crc32cValue<?> expected = Crc32cValue.of(expectedVal, 0);
144144
Crc32cValue.Crc32cLengthKnown actual = Crc32cValue.of(calculatedCrc32c, 0);
145145

146-
Hasher.defaultHasher().validate(expected, actual);
146+
hasher.validate(expected, actual);
147147
}
148148
} else {
149149
totalRead += read;
@@ -238,7 +238,7 @@ private ScatteringByteChannel open() {
238238

239239
boolean isHasherEnabled = !(hasher instanceof Hasher.NoOpHasher);
240240
boolean isFullObjectDownload = (request.getByteRangeSpec().getHttpRangeHeader() == null);
241-
if (isHasherEnabled && isFullObjectDownload) {
241+
if (isHasherEnabled && isFullObjectDownload && expectedCrc32cBase64 != null) {
242242
this.hashingInputStream = new HashingInputStream(Hashing.crc32c(), content);
243243
content = this.hashingInputStream;
244244
}

java-storage/google-cloud-storage/src/test/java/com/google/cloud/storage/ApiaryUnbufferedReadableByteChannelTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,15 @@ public void testRead_mismatchedCrc32cValidation_throwsChecksumMismatch() throws
121121
Hasher.defaultHasher()); ) {
122122

123123
ByteBuffer buf = ByteBuffer.allocate(4096);
124-
IOException expected =
124+
Hasher.ChecksumMismatchException expected =
125125
assertThrows(
126-
IOException.class,
126+
Hasher.ChecksumMismatchException.class,
127127
() -> {
128128
while (channel.read(new ByteBuffer[] {buf}, 0, 1) != -1) {
129129
buf.clear();
130130
}
131131
});
132132

133-
assertTrue(expected instanceof Hasher.ChecksumMismatchException);
134133
assertTrue(expected.getMessage().contains("Mismatch checksum value"));
135134
}
136135
}

0 commit comments

Comments
 (0)