Details
-
Type: Bug
-
Status: Open
-
Priority: 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.
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
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
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
{ buffer.deleteCharAt(buffer.lastIndexOf(",")); }if( buffer.length() > 0 && buffer.lastIndexOf(",") == (buffer.length() -1) )