Bug 46199 - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance
Summary: org.apache.poi.hssf.record.RecordFormatException: Unable to construct record ...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.2-FINAL
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-13 07:14 UTC by Duc Nguyen
Modified: 2008-11-17 08:57 UTC (History)
1 user (show)



Attachments
Input for this bug (541.50 KB, application/vnd.ms-excel)
2008-11-13 07:17 UTC, Duc Nguyen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duc Nguyen 2008-11-13 07:14:19 UTC
I try open a spreadsheet with POI 3.2-final. This is error message:


Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:186)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:328)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:271)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:196)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:178)
	at atd2ltdd.main(atd2ltdd.java:62)
Caused by: java.lang.ArrayIndexOutOfBoundsException
	at org.apache.poi.hssf.record.RecordInputStream.checkRecordPosition(RecordInputStream.java:142)
	at org.apache.poi.hssf.record.RecordInputStream.readInt(RecordInputStream.java:172)
	at org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord.<init>(EmbeddedObjectRefSubRecord.java:134)
	at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:52)
	at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:63)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:184)
	... 5 more
Comment 1 Duc Nguyen 2008-11-13 07:17:15 UTC
Created attachment 22860 [details]
Input for this bug
Comment 2 Josh Micich 2008-11-13 15:08:59 UTC
Fixed in svn r713852.

More tweaks to EmbeddedObjectRefSubRecord (also changed recently in bug 45912).  This record has an unusual encoding for one of its string fields: the unicode options byte is omitted when the string length is zero.  Prior to this fix, the code was not consistent about this.

Junit added.
Comment 3 Duc Nguyen 2008-11-14 08:21:39 UTC
After I get patch for EmbeddedObjectRefSubRecord.java in svn r713852, then compile POI. But this issue still appears.
Comment 4 Duc Nguyen 2008-11-15 23:56:11 UTC
Patch version of EmbeddedObjectRefSubRecord in r713852 imported some classes.
import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianInputStream;
import org.apache.poi.util.LittleEndianOutput;

But they're not in source code of POI 3.2-final.
Where do I get them ?
Comment 5 Josh Micich 2008-11-17 08:57:15 UTC
These files were added back in r707450.  I guess that was after POI-3.2-FINAL

From what I can see these files are present OK in svn trunk.  For example:
http://svn.apache.org/repos/asf/poi/trunk/src/java/org/apache/poi/util/LittleEndianInput.java

Please re-open if you are still having trouble.