fixed sonar bug closing resource