https://bz.apache.org/bugzilla/show_bug.cgi?id=66275
--- Comment #1 from [email protected] --- (In reply to vahapt from comment #0) > After SheetDataWriter.finalize() method is removed, > SheetDataWriter.dispose() is not called anymore. Thus _fd, the temporary > file created per sheet remains on disk. > > Solution suggestion, add the code to SheetDataWriter.close() method, sample > shown below: > > public void close() throws IOException > { > // this would break writing the same document multiple times: > _out.flush(); > _out.close(); > //Moved from finalize() method > if (!_fd.delete()) > { > logger.log(POILogger.ERROR, "Can't delete temporary encryption file: > "+_fd); > } > } Update: If the patch above is applied, SXSSFSheet.getWorksheetXMLInputStream() calls SheetDataWriter.close() while generating excel file and causes the temporary file to be deleted in the middle of processing. I'm not sure why _writer.close() call is there, theoretically inner _writer object should be closed when the sheet is closed. /* Gets "<sheetData>" document fragment*/ public InputStream getWorksheetXMLInputStream() throws IOException { // flush all remaining data and close the temp file writer flushRows(0); _writer.close(); return _writer.getWorksheetXMLInputStream(); } ----- If _writer.close() cannot be removed from SXSSFSheet.getWorksheetXMLInputStream() or will have severe side effects, secondary suggestion is to call SheetDataWriter.dispose() on SXSSFWorkbook.close() method. Patched version is provided below: @Override public void close() throws IOException { // ensure that any lingering writer is closed for (SXSSFSheet sheet : _xFromSxHash.values()) { try { SheetDataWriter _writer = sheet.getSheetDataWriter(); if (_writer != null) { _writer.close(); _writer.dispose(); //VahapT: Patch to instruct deletion of generated temporary file } } catch (IOException e) { LOG.atWarn().withThrowable(e).log("An exception occurred while closing sheet data writer for sheet {}.", sheet.getSheetName()); } } // Tell the base workbook to close, does nothing if // it's a newly created one _wb.close(); } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
