Fix resource leak

Fixed possible resource leak reported by checkstyle.