Remove usage of AutoCloseable to maintain JDK1.6 compatibility