Added Spring support and fixed a bug with the try-with-resources statements