do {
list.add(result.next());
} while (result.hasNext() && stopwatch.elapsedMillis() < MAX_MILLIS);
return new HistoryResult(list.build(), result.hasNext());
} finally {
tx.rollback();
}
} catch (PermanentFailure e) {
throw new IOException(e);
} catch (RetryableFailure e) {
// TODO(danilatos): Retry?