ICEfaces
  1. ICEfaces
  2. ICE-4371

Possible StringIndexOutOfBoundsException if you use ice:dataExporter component for a CSV file export

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.8
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      IE7, Firefox 3, Windows Vista

      Description

      If you use the new ice:dataExporter component for a CSV file export possible follow execption occurs:

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.AbstractStringBuilder.deleteCharAt(AbstractStringBuilder.java:770)
      at java.lang.StringBuffer.deleteCharAt(StringBuffer.java:382)
      at com.icesoft.faces.component.dataexporter.CSVOutputHandler.flushFile(CSVOutputHandler.java:18)
      at com.icesoft.faces.component.dataexporter.DataExporterRenderer.renderToHandler(DataExporterRenderer.java:271)
      at com.icesoft.faces.component.dataexporter.DataExporterRenderer.createFile(DataExporterRenderer.java:151)
      at com.icesoft.faces.component.dataexporter.DataExporterRenderer.encodeBegin(DataExporterRenderer.java:42)
             ....

      The previous named exception occurs if method "writeCell" in CSVOutputHandler wasn't called before flushing file.
      This constellation occurs only if no data available for export.

        Activity

        Hide
        Stefan Rempfer added a comment - - edited

        Check if buffer ends with a "," before delete sign to prevent execption ( Class: CSVOutputHandler, Method: flushFile)

        Original:
        ------------

        buffer.deleteCharAt(buffer.lastIndexOf(","));

        Fix:
        ------

        // check if buffer ends with a "," and necessary delete it
        if( buffer.length() > 0 && buffer.lastIndexOf(",") == (buffer.length() -1) )

        { buffer.deleteCharAt(buffer.lastIndexOf(",")); }
        Show
        Stefan Rempfer added a comment - - edited Check if buffer ends with a "," before delete sign to prevent execption ( Class: CSVOutputHandler, Method: flushFile) Original: ------------ buffer.deleteCharAt(buffer.lastIndexOf(",")); Fix: ------ // check if buffer ends with a "," and necessary delete it if( buffer.length() > 0 && buffer.lastIndexOf(",") == (buffer.length() -1) ) { buffer.deleteCharAt(buffer.lastIndexOf(",")); }

          People

          • Assignee:
            Unassigned
            Reporter:
            Stefan Rempfer
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: