### Question:
LabelScanValueIndexProgressor extends LabelScanValueIndexAccessor implements IndexProgressor, Resource { @Override public boolean next() { for ( ; ; ) { while ( bits != 0 ) { int delta = Long.numberOfTrailingZeros( bits ); bits &= bits - 1; if ( client.acceptNode( baseNodeId + delta, null ) ) { return true; } } try { if ( !cursor.next() ) { close(); return false; } } catch ( IOException e ) { throw new UncheckedIOException( e ); } Hit<LabelScanKey,LabelScanValue> hit = cursor.get(); baseNodeId = hit.key().idRange * LabelScanValue.RANGE_SIZE; bits = hit.value().bits; assert keysInOrder( hit.key() ); } } LabelScanValueIndexProgressor( RawCursor<Hit<LabelScanKey,LabelScanValue>,IOException> cursor,
            Collection<RawCursor<Hit<LabelScanKey,LabelScanValue>,IOException>> toRemoveFromWhenClosed,
            NodeLabelClient client ); @Override boolean next();  }### Answer:
@Test public void shouldCloseExhaustedCursors() throws Exception { RawCursor<Hit<LabelScanKey,LabelScanValue>,IOException> cursor = mock( RawCursor.class ); when( cursor.next() ).thenReturn( false ); Collection<RawCursor<Hit<LabelScanKey,LabelScanValue>,IOException>> toRemoveFrom = new HashSet<>(); LabelScanValueIndexProgressor iterator = new LabelScanValueIndexProgressor( cursor, toRemoveFrom, mock( IndexProgressor.NodeLabelClient.class ) ); verify( cursor, never() ).close(); exhaust( iterator ); verify( cursor, times( 1 ) ).close(); iterator.next(); verify( cursor, times( 1 ) ).close(); assertTrue( toRemoveFrom.isEmpty() ); }