File tree Expand file tree Collapse file tree 1 file changed +4
-17
lines changed
driver/src/main/java/org/neo4j/driver/internal Expand file tree Collapse file tree 1 file changed +4
-17
lines changed Original file line number Diff line number Diff line change 4242import org .neo4j .driver .v1 .util .Function ;
4343import org .neo4j .driver .v1 .util .Functions ;
4444
45- import static java .lang .String .format ;
4645import static java .util .Collections .emptyList ;
4746
4847public class InternalStatementResult implements StatementResult
@@ -222,7 +221,7 @@ else if ( done )
222221 @ Override
223222 public Record single ()
224223 {
225- if ( position > 0 )
224+ if ( position != - 1 )
226225 {
227226 throw new NoSuchRecordException (
228227 "Cannot retrieve the first record, because other operations have already used the first record. " +
@@ -274,12 +273,7 @@ public List<Record> list()
274273 @ Override
275274 public <T > List <T > list ( Function <Record , T > mapFunction )
276275 {
277- if ( isEmpty () )
278- {
279- assertOpen ();
280- return emptyList ();
281- }
282- else if ( position == -1 && hasNext () )
276+ if ( hasNext () )
283277 {
284278 List <T > result = new ArrayList <>();
285279 do
@@ -293,9 +287,8 @@ else if ( position == -1 && hasNext() )
293287 }
294288 else
295289 {
296- throw new ClientException (
297- format ( "Can't retain records when cursor is not pointing at the first record (currently at position %d)" , position )
298- );
290+ assertOpen ();
291+ return emptyList ();
299292 }
300293 }
301294
@@ -331,12 +324,6 @@ private void assertOpen()
331324 }
332325 }
333326
334- private boolean isEmpty ()
335- {
336- tryFetching ();
337- return position == -1 && recordBuffer .isEmpty () && done ;
338- }
339-
340327 private void tryFetching ()
341328 {
342329 while ( recordBuffer .isEmpty () && !done )
You can’t perform that action at this time.
0 commit comments