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

            Bug ID: 54625
           Summary: User defined functions added to static variable
           Product: POI
           Version: 3.9
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: [email protected]
          Reporter: [email protected]
    Classification: Unclassified

When registering a new User defined function as described here:

http://poi.apache.org/spreadsheet/user-defined-functions.html

In the case of the HSSF workbook

doing this:

workbook.addToolPack(udfToolpack);

adds the udfToolpack to a static variable. 

At the very least this could cause a bit of a memory leak, and in my case when
dealing with multiple workbooks in a single process, that have different
implementations for a particular UDF name, this statefulness means that the
first one registered is the one that always gets used.

I suggest changing this

private UDFFinder _udfFinder = UDFFinder.DEFAULT;

to this

private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.DEFAULT);

in org.apache.poi.hssf.usermodel.HSSFWorkbook

In the meantime, a suitable workaround for this issue is to create your own
implementation of a workbook factory, and when you create a HSSFWorkbook, use
reflection to set the appropriate value to the _udfFinder private variable.

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

Reply via email to