Skip to content

Commit

Permalink
tolerate null causes
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Parmet <[email protected]>
  • Loading branch information
andrewparmet committed Oct 6, 2023
1 parent 2a8c119 commit 6383a3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,15 @@ public <RequestT, ResponseT, ErrorT> ResponseT performRequest(
try {
return executeAsync((SdkAsyncHttpClient) httpClient, clientReq, requestBody, endpoint, options).get();
} catch (ExecutionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
} else {
throw new IOException(e.getCause());
Throwable cause = e.getCause();
if (cause != null) {
if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new IOException(cause);
}
}
throw new IOException(e);
} catch (InterruptedException e) {
throw new IOException("HttpRequest was interrupted", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,15 @@ public <RequestT, ResponseT, ErrorT> ResponseT performRequest(
try {
return performRequestAsync(request, endpoint, options).join();
} catch (final CompletionException ex) {
if (ex.getCause() instanceof IOException) {
throw (IOException) ex.getCause();
} else {
throw new IOException(ex.getCause());
Throwable cause = ex.getCause();
if (cause != null) {
if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new IOException(cause);
}
}
throw new IOException(ex);
}
}

Expand Down

0 comments on commit 6383a3f

Please sign in to comment.