Sonar: Correctly close resource