https://bz.apache.org/bugzilla/show_bug.cgi?id=58480
Bug ID: 58480
Summary: HSSFWorkbook.write(OutputStream) does not close the
NPOIFSFileSystem in use
Product: POI
Version: 3.13-dev
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
Assignee: [email protected]
Reporter: [email protected]
It seems that HSSFWorkbook's write(OutputStream) method is dependent on garbage
collection to close the NPOIFSFileSystem which is created in HSSFWorkbook line
1376 (POI v. 3.13).
We have an application where we first write the workbook to a byte-array and
then we copy that byte-array back to the original file location. Our copy
function will fail with FileNotFoundException "The process cannot access the
file because it is being used by another process."
What we finally discovered as a workaround for us is to call System.gc(),
System.runFinalization() and then Thread.sleep(1000) just after the
Workbook.write(..) call. But obviously this is a very silly way for us to work
around the issue.
The solution is quite simple: Create a try-finally block for the
NPOIFSFileSystem and make sure to close it in the finally-block.
--
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]