Skip to content

Commit 351729c

Browse files
author
Dhriti Chopra
committed
Fixing lint and small updates
1 parent 2db4acb commit 351729c

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
import com.google.api.gax.grpc.GrpcStatusCode;
2020
import com.google.cloud.storage.Crc32cValue.Crc32cLengthKnown;
2121
import com.google.protobuf.ByteString;
22-
import io.grpc.Status.Code;
2322
import com.google.storage.v2.Object;
23+
import io.grpc.Status.Code;
2424
import java.nio.ByteBuffer;
25+
import java.util.Locale;
2526
import java.util.OptionalLong;
2627
import java.util.function.Supplier;
2728

2829
/**
29-
* A wrapper around hasher that accumulates checksums and validates them at the
30-
* end of the read if it was a full object read.
30+
* A wrapper around hasher that accumulates checksums and validates them at the end of the read if
31+
* it was a full object read.
3132
*/
3233
final class CumulativeHasher implements Hasher {
3334
private final Hasher delegate;
@@ -53,7 +54,8 @@ public Crc32cLengthKnown hash(ByteString byteString) {
5354
}
5455

5556
@Override
56-
public void validate(Crc32cValue<?> expected, Supplier<ByteBuffer> b) throws ChecksumMismatchException {
57+
public void validate(Crc32cValue<?> expected, Supplier<ByteBuffer> b)
58+
throws ChecksumMismatchException {
5759
ByteBuffer byteBuffer = b.get();
5860
Crc32cLengthKnown actual = delegate.hash(byteBuffer);
5961
if (actual != null) {
@@ -65,7 +67,8 @@ public void validate(Crc32cValue<?> expected, Supplier<ByteBuffer> b) throws Che
6567
}
6668

6769
@Override
68-
public void validate(Crc32cValue<?> expected, ByteString byteString) throws ChecksumMismatchException {
70+
public void validate(Crc32cValue<?> expected, ByteString byteString)
71+
throws ChecksumMismatchException {
6972
Crc32cLengthKnown actual = delegate.hash(byteString);
7073
if (actual != null) {
7174
if (expected != null && !actual.eqValue(expected)) {
@@ -106,7 +109,8 @@ boolean qualifiesForVerification(Object metadata) {
106109
&& (!limit.isPresent() || limit.getAsLong() >= metadata.getSize());
107110
}
108111

109-
void validateCumulativeChecksum(Object metadata) throws UncheckedCumulativeChecksumMismatchException {
112+
void validateCumulativeChecksum(Object metadata)
113+
throws UncheckedCumulativeChecksumMismatchException {
110114
if (qualifiesForVerification(metadata)) {
111115
Crc32cValue<?> expected = Crc32cValue.of(metadata.getChecksums().getCrc32C());
112116
Crc32cLengthKnown actual = getCumulativeHash();
@@ -125,16 +129,19 @@ Crc32cLengthKnown getCumulativeHash() {
125129
}
126130
}
127131

128-
class UncheckedCumulativeChecksumMismatchException extends com.google.api.gax.rpc.DataLossException {
132+
final class UncheckedCumulativeChecksumMismatchException
133+
extends com.google.api.gax.rpc.DataLossException {
129134
private static final GrpcStatusCode STATUS_CODE = GrpcStatusCode.of(Code.DATA_LOSS);
130135
private final Crc32cValue<?> expected;
131136
private final Crc32cLengthKnown actual;
132137

133138
UncheckedCumulativeChecksumMismatchException(Crc32cValue<?> expected, Crc32cLengthKnown actual) {
134139
super(
135140
String.format(
141+
Locale.US,
136142
"Mismatch cumulative checksum value. Expected %s actual %s",
137-
expected.debugString(), actual.debugString()),
143+
expected.debugString(),
144+
actual.debugString()),
138145
/* cause= */ null,
139146
STATUS_CODE,
140147
/* retryable= */ false);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,3 @@ Crc32cLengthKnown getActual() {
258258
}
259259
}
260260
}
261-

0 commit comments

Comments
 (0)