poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 58480] New: HSSFWorkbook.write(OutputStream) does not close the NPOIFSFileSystem in use
Date Mon, 05 Oct 2015 10:09:16 GMT
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: dev@poi.apache.org
          Reporter: i.am.kasper.sorensen@gmail.com

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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message