ICEfaces
  1. ICEfaces
  2. ICE-7342

Improve ice:dataExporter memory usage

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-1.8.2.GA_P03
    • Fix Version/s: 3.0.RC1, 3.0, EE-1.8.2.GA_P04
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      -
    • Assignee Priority:
      P1

      Description

      A customer has the following dataExporter issues. They have a custom outputTypeHandler defined like so:

      <ice:dataExporter outputTypeHandler="#{table.excelDataTableExporter}" ... />

      The 'table' managed bean creates an instance of the custom class which extends com.icesoft.faces.component.dataexporter.ExcelOutputHandler and helps retrieve cell content/data depending on column. However I don't think this matters but worth mentioning. Here are their issues:

      1: The ExcelOutputHandler accepts a path as an input parameter and creates a blank excel file in it's constructor. If the user does not end up exporting the table, a blank excel file is still created on the server. If an application has 20-30 tables in it, these files will begin to accumulate rapidly. We should ensure that a file is only created when actually exporting the date.

      2: This may be related to 2. The exported files are not removed from memory when they are no longer needed (e.g. navigation) or the user's session is no longer valid. The deleteOnExit flag value appears to be true but the files are not deleted until the JVM terminates, which may not happen for months or years in a production environment.

        Activity

        Hide
        Tyler Johnson added a comment - - edited

        Hey Adnan, issue 1) should be reproducible in any dataExporter sample. Did you see a new file being created when using the dataExporter with our dataTable sample? Looking in DataExporter, I see that we create a new file here:

        public void broadcast(FacesEvent event)
        throws AbortProcessingException {
        super.broadcast(event);
        .........
        Resource res = getResource();
        if (res == null)

        { File output = createFile(facesContext, type, uiData); setResource(new FileResource(output)); getResource(); }

        Perhaps the resource is null?

        Show
        Tyler Johnson added a comment - - edited Hey Adnan, issue 1) should be reproducible in any dataExporter sample. Did you see a new file being created when using the dataExporter with our dataTable sample? Looking in DataExporter, I see that we create a new file here: public void broadcast(FacesEvent event) throws AbortProcessingException { super.broadcast(event); ......... Resource res = getResource(); if (res == null) { File output = createFile(facesContext, type, uiData); setResource(new FileResource(output)); getResource(); } Perhaps the resource is null?
        Hide
        Adnan Durrani added a comment - - edited

        Hi Tyler,

        Broadcast() gets executed only if export link gets clicked. So the above code snippet won't execute until you click export link.

        However the problem is in the constructor of OutputTypeHandler, which creates a file in its constructor.

        The dataExporter creates a static NoopOutputHandler which causing a new file named as "no-data", as it named as no-data, which gets removed after JVM termination.

        I modified the OutputTypeHandler component to not to create a file for NoopOutputHandler .

        Command: Commit
        Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java
        Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java
        Completed: At revision: 26141

        Show
        Adnan Durrani added a comment - - edited Hi Tyler, Broadcast() gets executed only if export link gets clicked. So the above code snippet won't execute until you click export link. However the problem is in the constructor of OutputTypeHandler, which creates a file in its constructor. The dataExporter creates a static NoopOutputHandler which causing a new file named as "no-data", as it named as no-data, which gets removed after JVM termination. I modified the OutputTypeHandler component to not to create a file for NoopOutputHandler . Command: Commit Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java Completed: At revision: 26141
        Hide
        Adnan Durrani added a comment - - edited

        I still would like to see an example of custom OutputTypeHandler. Please if you can attach a working war with src, it will be great.

        Show
        Adnan Durrani added a comment - - edited I still would like to see an example of custom OutputTypeHandler. Please if you can attach a working war with src, it will be great.
        Hide
        Tyler Johnson added a comment -

        Attaching a new example custom outputTypeHandler that has no outside dependencies.

        Show
        Tyler Johnson added a comment - Attaching a new example custom outputTypeHandler that has no outside dependencies.
        Hide
        Ken Fyten added a comment -

        Should this change also be applies to the IF 2.1 compat ice:dataExporter component?

        Show
        Ken Fyten added a comment - Should this change also be applies to the IF 2.1 compat ice:dataExporter component?
        Hide
        Adnan Durrani added a comment - - edited

        Command: Commit
        Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java
        Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java
        Completed: At revision: 26340

        Command: Commit
        Modified: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java
        Modified: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java
        Sending content: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java
        Sending content: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java
        Completed: At revision: 26341

        Show
        Adnan Durrani added a comment - - edited Command: Commit Modified: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java Sending content: D:\work\development\head\svn\ossrepo\icefaces\trunk\icefaces\component\src\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java Completed: At revision: 26340 Command: Commit Modified: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java Modified: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java Sending content: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\OutputTypeHandler.java Sending content: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\DataExporterRenderer.java Completed: At revision: 26341
        Hide
        Adnan Durrani added a comment -

        Changes made to the code so it will not call getOutputTypeHandler() until link gets clicked to download a file. However its developer's responsibility to create outputTypeHandler lazily if using one (e.g.)

        public class MyBean {

        private CustomExcelExporter handler; // don't instantiate here.

        public OutputTypeHandler getHandler() {
        if (null == handler)

        { handler = new CustomExcelExporter(); }

        return handler;
        }
        }

        Show
        Adnan Durrani added a comment - Changes made to the code so it will not call getOutputTypeHandler() until link gets clicked to download a file. However its developer's responsibility to create outputTypeHandler lazily if using one (e.g.) public class MyBean { private CustomExcelExporter handler; // don't instantiate here. public OutputTypeHandler getHandler() { if (null == handler) { handler = new CustomExcelExporter(); } return handler; } }

          People

          • Assignee:
            Adnan Durrani
            Reporter:
            Tyler Johnson
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: