Merge "Fix error throwing by calling getCount before closing the cursor." into main