Remove unused async cursor tryNext support
Inline method that's now only used in one place.
@@ -151,7 +151,32 @@ class AsyncQueryBatchCursor<T> implements AsyncAggregateResponseBatchCursor<T> {
@Override
public void next(final SingleResultCallback<List<T>> callback) {
- internalNext(callback);
+ if (isClosed()) {
+ callback.onResult(null, new MongoException("next() called after the cursor was closed."));
+ } else if (firstBatch != null && (!firstBatch.getResults().isEmpty())) {
+ // May be empty for a tailable cursor
+ List<T> results = firstBatch.getResults();
+ firstBatch = null;
+ if (getServerCursor() == null) {
+ close();
+ }
+ callback.onResult(results, null);
+ } else {
+ ServerCursor localCursor = getServerCursor();
+ if (localCursor == null) {
+ close();
+ callback.onResult(null, null);
+ } else {
+ synchronized (this) {
+ if (isClosed()) {
+ callback.onResult(null, new MongoException("next() called after the cursor was closed."));
+ return;
+ }
+ isOperationInProgress = true;
+ }
+ getMore(localCursor, callback);
+ }
+ }
}
@Override
@@ -193,35 +218,6 @@ class AsyncQueryBatchCursor<T> implements AsyncAggregateResponseBatchCursor<T> {
return maxWireVersion;
}
- private void internalNext(final SingleResultCallback<List<T>> callback) {
- if (isClosed()) {
- callback.onResult(null, new MongoException("next() called after the cursor was closed."));
- } else if (firstBatch != null && (!firstBatch.getResults().isEmpty())) {
- // May be empty for a tailable cursor
- List<T> results = firstBatch.getResults();
- firstBatch = null;
- if (getServerCursor() == null) {
- close();
- }
- callback.onResult(results, null);
- } else {
- ServerCursor localCursor = getServerCursor();
- if (localCursor == null) {
- close();
- callback.onResult(null, null);
- } else {
- synchronized (this) {
- if (isClosed()) {
- callback.onResult(null, new MongoException("next() called after the cursor was closed."));
- return;
- }
- isOperationInProgress = true;
- }
- getMore(localCursor, callback);
- }
- }
- }
-
private boolean limitReached() {
return Math.abs(limit) != 0 && count.get() >= Math.abs(limit);
}
