use try with resources statement

Change-Id: I84510ae7e2f3da70c54b78b39e4c69184d32aca7