in src/main/java/com/awslabs/resultsiterator/implementations/ResultsIteratorAbstract.java [136:166]
private AwsResponse queryNextResults(AwsRequest request) {
if (clientMethodReturningResult == null) {
// Look for a public method in the client (AWSIot, etc) that takes a AwsRequest and returns a V. If zero or more than one exists, fail.
clientMethodReturningResult = reflectionHelper.getMethodWithParameterAndReturnType(sdkClient.getClass(), awsRequestClass, getResponseClass());
}
if (clientMethodReturningResult.isEmpty()) {
throw new UnsupportedOperationException("Failed to find a method returning the expected response type, this should never happen.");
}
try {
// This is necessary because these methods are not accessible by default
clientMethodReturningResult.get().setAccessible(true);
return (AwsResponse) clientMethodReturningResult.get().invoke(sdkClient, request);
} catch (IllegalAccessException e) {
e.printStackTrace();
throw new UnsupportedOperationException(e);
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof SdkClientException) {
SdkClientException sdkClientException = (SdkClientException) e.getTargetException();
if (sdkClientException.getMessage().contains("Unable to execute HTTP request")) {
log.error("Unable to connect to the API. Do you have an Internet connection?");
return null;
}
}
e.printStackTrace();
throw new UnsupportedOperationException(e);
}
}