Bug 30772

Summary: ArrayIndexOutOfBoundsException when creating HSSFWorkbook object for very large XLS file
Product: POI Reporter: Marco Miljak <marco.miljak>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P3    
Version: 2.5-FINAL   
Target Milestone: ---   
Hardware: All   
OS: Windows XP   
Bug Depends on: 27929    
Bug Blocks:    

Description Marco Miljak 2004-08-20 12:20:29 UTC
I've tried to read in a very large XLS file with 10 sheets and with a big bunch 
of data on every sheet. When creating the HSSFWorkbook object for that file I 
get an ArrayIndexOutOfBounds exception (code below).

java.lang.reflect.InvocationTargetException: java.lang.
ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
	at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:57)
	at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
	at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
	at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
	at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:
224)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:
160)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
	at POI1.main(POI1.java:23)
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record 
instance, the following exception occured: null
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:
237)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:
160)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
	at POI1.main(POI1.java:23)
Exception in thread "main" 

The code I used was:

POIFSFileSystem fs = new POIFSFileSystem( new FileInputStream(args[0] ) );	
HSSFWorkbook wb = new HSSFWorkbook( fs ); // Exception here!!!

To confirm that bug I tried a smaller XLS file and it worked fine. Maybe it's
because of the heavy use of 'short' symbols in POI.
Comment 1 Glen Stampoultzis 2004-09-19 01:36:09 UTC
Without a sample spreadsheet it's difficult to tell what the issue is.  Please
attach one.
Comment 2 Glen Stampoultzis 2004-09-19 02:34:59 UTC
Actually come to think of it I think I do know the cause of this one.  I think
it is due to bug 27929.  A patch for this has been applied.  Please checkout
HEAD from CVS and give it a shot.  I'll resolve as fixed for now.  If it's not
fixed then please reopen.