Avoid leaking cursors

Adding try/finally blocks to make sure that cursor
resources are let go

Change-Id: I596074aa9ab5752f91a26b5a03e1f39c23c64a5f
Automatic translation import

Change-Id: I5d66d07ff7826979e6b27dd5e83acf3f3f9f2c44
Automatic translation import

Change-Id: I349dab94b12ba0bbd02a433bcbc92a4e1c6d48bf
Automatic translation import

Change-Id: Ib7049fea2926c61187d915adfddfc87c362e73a4