You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2014/06/09 19:46:36 UTC

[Bug 56609] New: Resource leak in WorkbookFactory.create()

https://issues.apache.org/bugzilla/show_bug.cgi?id=56609

            Bug ID: 56609
           Summary: Resource leak in WorkbookFactory.create()
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POI Overall
          Assignee: dev@poi.apache.org
          Reporter: dlazerka@gmail.com

WorkbookFactory.create() does not close the filesystem it opens, so after some
time server JVM crashes with "Too many open files" error.

I've read bug 56537, but disagree the proposed workaround -- to copy-paste
create() source code, because it's not evident that it leaks resource (until it
goes to production). There's no warnings in create() javadoc about the leak, so
there's no reason for user to not trust it does the right thing.

I think it's better to not have the method at all, to force user to care about
closing file handles (before the buggy code is pushed to production servers,
not after). In the way it is currently, it's certainly not industry-reliable:
it not only stops creating Workbook-s, it crashes the whole JVM with all the
services in the JVM.

Or, to make it to close file handles automatically in any way you prefer.

-- 
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


[Bug 56609] Resource leak in WorkbookFactory.create()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56609

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
The JavaDocs already have a note on this, see
http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/WorkbookFactory.html#create%28java.io.File%29
- "Note that for Workbooks opened this way, it is not possible to explicitly
close the underlying File resource."

I believe that these files should be cleaned up during garbage collection,
assuming you don't have references to them, so for most people it won't be a
problem

If someone is able to come up with a new pattern which maintains the simplicity
of WorkbookFactory and the low memory footprint of using a File (vs a Stream),
and also allows for explicit closing, then we'll happily apply that!

-- 
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


[Bug 56609] Resource leak in WorkbookFactory.create()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56609

--- Comment #3 from Dzmitry Lazerka <dl...@gmail.com> ---
Thanks for the JavaDoc.
Nick Burch, the files are not cleaned up during garbage collection, because
they are not Java objects -- these are lower level system resources (unix file
handles). Once a process goes over the limit of open file handles, OS prevents
it from opening new ones. For JVM that means crash. We found out that on
production :)
That's why I was advocating removing the method at all -- because it crashes
the whole system, not only POI-related features.

-- 
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


[Bug 56609] Resource leak in WorkbookFactory.create()

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56609

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
As part of Bug 56537 we have added interface Closeable to the Workbook class
which means resources can be freed by properly closing the object after use.
Javadoc will be updated as well to reflect this. 

So I think this is effectively a duplicate now.

*** This bug has been marked as a duplicate of bug 56537 ***

-- 
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