Skip to content

Commit 3ff3e8a

Browse files
committed
Remove unused async cursor tryNext support
Inline method that's now only used in one place. JAVA-3972
1 parent 6fa9a0b commit 3ff3e8a

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

driver-core/src/main/com/mongodb/internal/operation/AsyncQueryBatchCursor.java

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,32 @@ public void close() {
151151

152152
@Override
153153
public void next(final SingleResultCallback<List<T>> callback) {
154-
internalNext(callback);
154+
if (isClosed()) {
155+
callback.onResult(null, new MongoException("next() called after the cursor was closed."));
156+
} else if (firstBatch != null && (!firstBatch.getResults().isEmpty())) {
157+
// May be empty for a tailable cursor
158+
List<T> results = firstBatch.getResults();
159+
firstBatch = null;
160+
if (getServerCursor() == null) {
161+
close();
162+
}
163+
callback.onResult(results, null);
164+
} else {
165+
ServerCursor localCursor = getServerCursor();
166+
if (localCursor == null) {
167+
close();
168+
callback.onResult(null, null);
169+
} else {
170+
synchronized (this) {
171+
if (isClosed()) {
172+
callback.onResult(null, new MongoException("next() called after the cursor was closed."));
173+
return;
174+
}
175+
isOperationInProgress = true;
176+
}
177+
getMore(localCursor, callback);
178+
}
179+
}
155180
}
156181

157182
@Override
@@ -193,35 +218,6 @@ public int getMaxWireVersion() {
193218
return maxWireVersion;
194219
}
195220

196-
private void internalNext(final SingleResultCallback<List<T>> callback) {
197-
if (isClosed()) {
198-
callback.onResult(null, new MongoException("next() called after the cursor was closed."));
199-
} else if (firstBatch != null && (!firstBatch.getResults().isEmpty())) {
200-
// May be empty for a tailable cursor
201-
List<T> results = firstBatch.getResults();
202-
firstBatch = null;
203-
if (getServerCursor() == null) {
204-
close();
205-
}
206-
callback.onResult(results, null);
207-
} else {
208-
ServerCursor localCursor = getServerCursor();
209-
if (localCursor == null) {
210-
close();
211-
callback.onResult(null, null);
212-
} else {
213-
synchronized (this) {
214-
if (isClosed()) {
215-
callback.onResult(null, new MongoException("next() called after the cursor was closed."));
216-
return;
217-
}
218-
isOperationInProgress = true;
219-
}
220-
getMore(localCursor, callback);
221-
}
222-
}
223-
}
224-
225221
private boolean limitReached() {
226222
return Math.abs(limit) != 0 && count.get() >= Math.abs(limit);
227223
}

0 commit comments

Comments
 (0)