File tree Expand file tree Collapse file tree 1 file changed +3
-21
lines changed
firebase-firestore/src/main/java/com/google/firebase/firestore/local Expand file tree Collapse file tree 1 file changed +3
-21
lines changed Original file line number Diff line number Diff line change @@ -505,18 +505,12 @@ int forEach(Consumer<Cursor> consumer) {
505
505
* @return The number of rows processed (either zero or one).
506
506
*/
507
507
int first (Consumer <Cursor > consumer ) {
508
- Cursor cursor = null ;
509
- try {
510
- cursor = startQuery ();
508
+ try (Cursor cursor = startQuery ()) {
511
509
if (cursor .moveToFirst ()) {
512
510
consumer .accept (cursor );
513
511
return 1 ;
514
512
}
515
513
return 0 ;
516
- } finally {
517
- if (cursor != null ) {
518
- cursor .close ();
519
- }
520
514
}
521
515
}
522
516
@@ -530,30 +524,18 @@ int first(Consumer<Cursor> consumer) {
530
524
*/
531
525
@ Nullable
532
526
<T > T firstValue (Function <Cursor , T > function ) {
533
- Cursor cursor = null ;
534
- try {
535
- cursor = startQuery ();
527
+ try (Cursor cursor = startQuery ()) {
536
528
if (cursor .moveToFirst ()) {
537
529
return function .apply (cursor );
538
530
}
539
531
return null ;
540
- } finally {
541
- if (cursor != null ) {
542
- cursor .close ();
543
- }
544
532
}
545
533
}
546
534
547
535
/** Runs the query and returns true if the result was nonempty. */
548
536
boolean isEmpty () {
549
- Cursor cursor = null ;
550
- try {
551
- cursor = startQuery ();
537
+ try (Cursor cursor = startQuery ()) {
552
538
return !cursor .moveToFirst ();
553
- } finally {
554
- if (cursor != null ) {
555
- cursor .close ();
556
- }
557
539
}
558
540
}
559
541
You can’t perform that action at this time.
0 commit comments