Fix connection leak when requested object file does not exist on disk

* first create connection
* then open it for reading (potentially resulting in error condition)
* always close it (destroying connection) before erring out