Source:
private DynamoDBResponse query(final QueryRequest originalQueryRequest) { final List<Map<String, AttributeValue>> results = Lists.newArrayList(); Map<String, AttributeValue> lastEvaluatedKey = null; int numAttempts = 0; boolean keepTrying = true; do { numAttempts++; final QueryRequest queryRequest = originalQueryRequest .clone() .withExclusiveStartKey(lastEvaluatedKey); final QueryResult queryResult; try { queryResult = this.dynamoDBClient.query(queryRequest); } catch (ProvisionedThroughputExceededException ptee) { if (numAttempts >= maxQueryAttempts()) { logger().warn("Got ProvisionedThroughputExceededException while querying. Query: {}", queryRequest.getExpressionAttributeValues()); return new DynamoDBResponse(results, Response.Status.PARTIAL_RESULTS, Optional.of(ptee)); } backoff(numAttempts); continue; } catch (ResourceNotFoundException rnfe) { logger().error("Got ResourceNotFoundException while attempting to read from table {}; {}", queryRequest.getTableName(), rnfe); return new DynamoDBResponse(results, Response.Status.FAILURE, Optional.of(rnfe)); } final List<Map<String, AttributeValue>> items = queryResult.getItems(); if (queryResult.getItems() != null) { for (final Map<String, AttributeValue> item : items) { results.add(item); } } lastEvaluatedKey = queryResult.getLastEvaluatedKey(); keepTrying = (lastEvaluatedKey != null); } while (keepTrying && (numAttempts < maxQueryAttempts())); final Response.Status status; if (lastEvaluatedKey != null) { logger().warn("Exceeded attempts while querying. Stopping with last evaluated key: {}", maxQueryAttempts(), lastEvaluatedKey); status = Response.Status.PARTIAL_RESULTS; } else { status = Response.Status.SUCCESS; } return new DynamoDBResponse(results, status, Optional.<Exception>absent()); }

Target:
private DynamoDBResponse query(final QueryRequest originalQueryRequest) { final List<Map<String, AttributeValue>> results = Lists.newArrayList(); Map<String, AttributeValue> lastEvaluatedKey = null; int numAttempts = 0; boolean keepTrying = true; do { numAttempts++; final QueryRequest queryRequest = originalQueryRequest .clone() .withExclusiveStartKey(lastEvaluatedKey); final QueryResult queryResult; try { queryResult = this.dynamoDBClient.query(queryRequest); } catch (ProvisionedThroughputExceededException ptee) { if (numAttempts >= maxQueryAttempts()) { logger().warn("exception=dynamodb-read-throughput method=query table={} expressionAttributeValues={}", queryRequest.getTableName(), queryRequest.getExpressionAttributeValues()); return new DynamoDBResponse(results, Response.Status.PARTIAL_RESULTS, Optional.of(ptee)); } backoff(numAttempts); continue; } catch (ResourceNotFoundException rnfe) { logger().error("Got ResourceNotFoundException while attempting to read from table {}; {}", queryRequest.getTableName(), rnfe); return new DynamoDBResponse(results, Response.Status.FAILURE, Optional.of(rnfe)); } final List<Map<String, AttributeValue>> items = queryResult.getItems(); if (queryResult.getItems() != null) { for (final Map<String, AttributeValue> item : items) { results.add(item); } } lastEvaluatedKey = queryResult.getLastEvaluatedKey(); keepTrying = (lastEvaluatedKey != null); } while (keepTrying && (numAttempts < maxQueryAttempts())); final Response.Status status; if (lastEvaluatedKey != null) { logger().warn("Exceeded attempts while querying. Stopping with last evaluated key: {}", maxQueryAttempts(), lastEvaluatedKey); status = Response.Status.PARTIAL_RESULTS; } else { status = Response.Status.SUCCESS; } return new DynamoDBResponse(results, status, Optional.<Exception>absent()); }