"api" in finally block is not necessarily defined yet