Skip to content

Commit 919e67b

Browse files
address linter
1 parent 9e48440 commit 919e67b

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageReadChannel.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
@ThreadSafe
4343
final class CloudStorageReadChannel implements SeekableByteChannel {
4444

45+
private final Storage gcsStorage;
46+
private final BlobId file;
4547
private ReadChannel channel;
4648
private long position;
4749
private long size;
48-
private Storage gcsStorage;
49-
private BlobId file;
5050
// max # of times we may reopen the file
5151
private final int maxReopen;
5252
// how many times we re-opened the file
@@ -109,29 +109,23 @@ public int read(ByteBuffer dst) throws IOException {
109109
} catch (StorageException exs) {
110110
// this error isn't marked as retryable since the channel is closed;
111111
// but here at this higher level we can retry it.
112-
if (exs.getMessage().contains("Connection closed prematurely")) {
113-
if (reopens < maxReopen) {
114-
reopens++;
115-
retryDelay(reopens);
116-
innerOpen();
117-
continue;
118-
}
119-
} else if (exs.getCode() == 500) {
112+
if (exs.getMessage().contains("Connection closed prematurely") && reopens < maxReopen) {
113+
reopens++;
114+
retryDelay(reopens);
115+
innerOpen();
116+
continue;
117+
} else if (exs.getCode() == 500 && retries < maxRetries) {
120118
// server error. Not retryable yet retrying works in my experience.
121-
if (retries < maxRetries) {
122-
retries++;
123-
retryDelay(retries);
124-
continue;
125-
}
126-
} else if (exs.getCode() == 503) {
119+
retries++;
120+
retryDelay(retries);
121+
continue;
122+
} else if (exs.getCode() == 503 && retries < maxRetries) {
127123
// server temporarily unavailable. Marked not retriable,
128124
// yet retrying works in my experience.
129-
if (retries < maxRetries) {
130-
retries++;
131-
// wait a bit more since this error suggests the server's busy
132-
retryDelay(retries + 1);
133-
continue;
134-
}
125+
retries++;
126+
// wait a bit more since this error suggests the server's busy
127+
retryDelay(retries + 1);
128+
continue;
135129
}
136130
throw exs;
137131
}

0 commit comments

Comments
 (0)