Skip to content

Commit 7c81e40

Browse files
Fix reviewer and machine comments
1 parent 2fddc77 commit 7c81e40

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public int read(ByteBuffer dst) throws IOException {
108108
amt = channel.read(dst);
109109
break;
110110
} catch (StorageException exs) {
111-
if (reopens < maxChannelReopens && (isReopenable(exs) || isReopenable(exs.getCause()))) {
111+
if (reopens < maxChannelReopens && isReopenable(exs)) {
112112
// these errors aren't marked as retryable since the channel is closed;
113113
// but here at this higher level we can retry them.
114114
reopens++;
@@ -136,13 +136,16 @@ public int read(ByteBuffer dst) throws IOException {
136136
}
137137

138138
private static boolean isReopenable(Throwable exs) {
139-
while (exs != null) {
140-
if (exs.getMessage().contains("Connection closed prematurely")
141-
|| exs.getCause() instanceof javax.net.ssl.SSLException
142-
|| exs.getCause() instanceof java.io.EOFException
143-
|| exs.getCause() instanceof java.net.SocketException
144-
|| exs.getCause() instanceof java.net.SocketTimeoutException) return true;
145-
exs = exs.getCause();
139+
Throwable throwable = exs;
140+
while (throwable != null) {
141+
if (throwable.getMessage().contains("Connection closed prematurely")
142+
|| throwable.getCause() instanceof javax.net.ssl.SSLException
143+
|| throwable.getCause() instanceof java.io.EOFException
144+
|| throwable.getCause() instanceof java.net.SocketException
145+
|| throwable.getCause() instanceof java.net.SocketTimeoutException) {
146+
return true;
147+
}
148+
throwable = throwable.getCause();
146149
}
147150
return false;
148151
}

0 commit comments

Comments
 (0)