Ensure workbooks are closed after reading/writing

This commit is contained in:
Owen Stephens 2019-04-09 15:02:10 +01:00
parent 461b352035
commit e2aa929908
3 changed files with 4 additions and 3 deletions

View File

@ -141,8 +141,8 @@ public class XlsExporter implements StreamExporter {
project, engine, params, serializer); project, engine, params, serializer);
wb.write(outputStream); wb.write(outputStream);
wb.close();
outputStream.flush(); outputStream.flush();
wb.close();
} }
} }

View File

@ -117,6 +117,7 @@ public class ExcelImporter extends TabularImportingParserBase {
} }
JSONUtilities.append(sheetRecords, sheetRecord); JSONUtilities.append(sheetRecords, sheetRecord);
} }
wb.close();
} finally { } finally {
is.close(); is.close();
} }
@ -146,7 +147,6 @@ public class ExcelImporter extends TabularImportingParserBase {
Workbook wb = null; Workbook wb = null;
if (!inputStream.markSupported()) { if (!inputStream.markSupported()) {
inputStream = new BufferedInputStream(inputStream); inputStream = new BufferedInputStream(inputStream);
;
} }
try { try {
@ -238,7 +238,7 @@ public class ExcelImporter extends TabularImportingParserBase {
exceptions exceptions
); );
} }
super.parseOneFile(project, metadata, job, fileSource, inputStream, limit, options, exceptions); super.parseOneFile(project, metadata, job, fileSource, inputStream, limit, options, exceptions);
} }

View File

@ -222,6 +222,7 @@ public class ExcelImporterTests extends ImporterTest {
wb.write(outputStream); wb.write(outputStream);
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
wb.close();
} catch (IOException e) { } catch (IOException e) {
return null; return null;
} }