@Override public ScanResult next() { ExponentialBackoff.Scan backoff = new ExponentialBackoff.Scan(request, delegate, lastConsumedCapacity); ScanResult result = null; try { result = backoff.runWithBackoff(); // this will be non-null or runWithBackoff throws } catch (BackendException e) { throw new BackendRuntimeException(e); } if (result.getConsumedCapacity() != null) { lastConsumedCapacity = result.getConsumedCapacity().getCapacityUnits().intValue(); } if (result.getLastEvaluatedKey() != null && !result.getLastEvaluatedKey().isEmpty()) { hasNext = true; request.setExclusiveStartKey(result.getLastEvaluatedKey()); } else { hasNext = false; } return result; }