@Override public void teardown() { IOException savedException = null; boolean fileFailed = false; try { if (inputStream != null) { inputStream.close(); } } catch (IOException ex) { savedException = ex; fileFailed = true; } boolean fsFailed = false; try { fs.close(); } catch (IOException ex) { savedException = ex; fsFailed = true; } if (savedException != null) { String errorMessage = ""; if (fileFailed) { errorMessage += "Failed to close " + currentFile + ". "; } if (fsFailed) { errorMessage += "Failed to close filesystem."; } throw new RuntimeException(errorMessage, savedException); } idempotentStorageManager.teardown(); }