Bug 19862 - [PATCH] Runtime Exception in NameRecord.java
Summary: [PATCH] Runtime Exception in NameRecord.java
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: All other
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-12 18:07 UTC by John Lloyd
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
This file causes the exception when processed by HSSFWorkbook (186.50 KB, application/octet-stream)
2003-05-12 18:11 UTC, John Lloyd
Details
Patch file made from 1.10.0 developer build (791 bytes, patch)
2003-05-12 18:12 UTC, John Lloyd
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Lloyd 2003-05-12 18:07:39 UTC
While processing an Excel file (available upon request) with HSSF, I got a run-
time exception in the method NameRecord.fillFields(). I looked at the code and 
found a bug in line 658 of that method in the file NameRecord.java in version 
1.10.0. The code should be adding the length of the previous variable length 
field to find the start of the current field. Instead it is adding the length 
of the current field. I changed the line as below to solve the problem. How do 
I get this change into the HSSF base?

          //int start_of_description_text   = start_of_custom_menu_text + 
field_8_length_description_text;
	    int start_of_description_text   = start_of_custom_menu_text + 
field_7_length_custom_menu;

The exception occurs with some macros as below with the 1.10.0 developer 
release. 

java.lang.reflect.InvocationTargetException:
java.lang.StringIndexOutOfBoundsException: String index out of range: 63
        at java.lang.String.<init>(Unknown Source)
        at java.lang.String.<init>(Unknown Source)
        at
org.apache.poi.hssf.record.NameRecord.fillFields(NameRecord.java:633)

        at org.apache.poi.hssf.record.Record.fillFields(Record.java:143)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:105)
        at
org.apache.poi.hssf.record.NameRecord.<init>(NameRecord.java:121)
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:254)
        at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:192)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:187)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:234)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:215)
        at
com.ibm.wps.odc.convert.sheet.ExcelReader.read(ExcelReader.java:118)
Comment 1 John Lloyd 2003-05-12 18:11:04 UTC
Created attachment 6327 [details]
This file causes the exception when processed by HSSFWorkbook
Comment 2 John Lloyd 2003-05-12 18:12:35 UTC
Created attachment 6328 [details]
Patch file made from 1.10.0 developer build
Comment 3 Danny Mui 2003-05-17 18:36:50 UTC
Committed 05/17/2003.

Thanks for the contribution, please verify.  Would highly appreciate test cases
in the future to prevent this bug from resurfacing and speed patching along.

Thanks again!