Bug 15228 - [Urgent] ArrayIndexoutofbounds Exception. POI - Version 1.8
Summary: [Urgent] ArrayIndexoutofbounds Exception. POI - Version 1.8
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P1 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2002-12-10 12:15 UTC by gvdinesh
Modified: 2005-03-20 17:06 UTC (History)
1 user (show)

sample excel file (648.50 KB, application/octet-stream)
2002-12-12 14:41 UTC, gvdinesh

Note You need to log in before you can comment on or make changes to this bug.
Description gvdinesh 2002-12-10 12:15:25 UTC
While trying to update a column in a excel file of size 700KB, which also 
contains macros, I am getting arrayindexoutofbounds exception.

The exception is,

	at org.apache.poi.util.LittleEndian.getNumber(LittleEndian.java:557)
	at org.apache.poi.util.LittleEndian.getShort(LittleEndian.java:90)
	at org.apache.poi.hssf.record.formula.NamePtg.<init>(NamePtg.java:100)
	at org.apache.poi.hssf.record.formula.Ptg.createPtg(Ptg.java:247)
	at org.apache.poi.hssf.record.FormulaRecord.getParsedExpressionTokens
	at org.apache.poi.hssf.record.FormulaRecord.fillFields
	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.FormulaRecord.<init>
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at org.apache.poi.hssf.record.RecordFactory.createRecord
	at org.apache.poi.hssf.record.RecordFactory.createRecords
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
	at com.selectica.server.framework.CxCommandExecutor.process
	at com.selectica.server.framework.CxCommandExecutorRunnable.run
	at java.lang.Thread.run(Thread.java:484)

Comment 1 Andy Oliver 2002-12-10 17:12:30 UTC
do NOT reassign bugs to me.
Comment 2 Avik Sengupta 2002-12-12 07:46:51 UTC
This information is NOT enough to debug and/or solve this problem. Please attach
problem .xls and the minumum amount of (compilable) code needed to replicate
this issue. We can then try and resolve this issue. 

Also, to reiterate, assigning bugs to individuals in a voluteer project is
presumptious, to say the least.  
Comment 3 gvdinesh 2002-12-12 14:41:20 UTC
Created attachment 4141 [details]
sample excel file
Comment 4 gvdinesh 2002-12-12 14:42:25 UTC
Added attachment file.

This file even fails read.

Sorry for assigning the bug to Andy.

Comment 5 gvdinesh 2002-12-17 15:51:10 UTC
I tried to trace through the code. In littleEndian.java 

 private static long getNumber(final byte[] data, final int offset,          
final int size)

the data length is smaller than offset+size-1 and the for loop there fails. So 
it is giving a error while executing the attached file.

Any insights into it.

Comment 6 Paul Krause 2002-12-17 15:55:09 UTC
Is this possibly the same as bug 13292?
Comment 7 Andy Oliver 2003-07-24 14:03:34 UTC
This is fixed and awaiting commit
Comment 8 Avik Sengupta 2003-07-27 19:26:20 UTC
Fixed. comitted to both branch and head. will go into 2.0pre3 release. 
Comment 9 Clay Richardson 2003-08-12 17:56:36 UTC
I am still having this problem with 2.0-pre3.  I have about twenty Excel files, 
all seemingly the same (structurally) and I am batch processing them with Ant, 
and running to this error on half to three quarters of them.

Here is a stack trace:

       [excel] java.lang.reflect.InvocationTargetException
       [excel] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(Native Method)
       [excel] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance
(Unknown Source)
       [excel] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(Unknown Source)
       [excel] 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
       [excel] 	at org.apache.poi.hssf.record.RecordFactory.createRecord
       [excel] 	at org.apache.poi.hssf.record.RecordFactory.createRecords
       [excel] 	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
       [excel] 	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
       [excel] 	at com.etg.ant.ExcelTask.execute(ExcelTask.java:90)
       [excel] 	at com.etg.ant.ExcelTask.execute(ExcelTask.java:61)
       [excel] 	at org.apache.tools.ant.Task.perform(Task.java:319)
       [excel] 	at org.apache.tools.ant.Target.execute(Target.java:309)
       [excel] 	at org.apache.tools.ant.Target.performTasks(Target.java:336)
       [excel] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
       [excel] 	at org.apache.tools.ant.Project.executeTargets
       [excel] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run
       [excel] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run
       [excel] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [excel] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       [excel] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown 
       [excel] 	at java.lang.reflect.Method.invoke(Unknown Source)
       [excel] 	at org.eclipse.ant.core.AntRunner.run(AntRunner.java:335)
       [excel] 	at 
       [excel] 	at java.lang.Thread.run(Unknown Source)
       [excel] Caused by: java.lang.ArrayIndexOutOfBoundsException: 11
       [excel] 	at org.apache.poi.util.LittleEndian.getNumber
       [excel] 	at org.apache.poi.util.LittleEndian.getInt
       [excel] 	at org.apache.poi.hssf.record.BOFRecord.fillFields
       [excel] 	at org.apache.poi.hssf.record.Record.fillFields(Record.java:127)
       [excel] 	at org.apache.poi.hssf.record.Record.<init>(Record.java:92)
       [excel] 	at org.apache.poi.hssf.record.BOFRecord.<init>
       [excel] 	... 24 more

I am looking into whether I can permission to give you one of the files that is 
bombing out, but that may take a little longer, and may not be allowable. 
*sorry, not my call*  :(
Comment 10 Avik Sengupta 2003-08-23 20:02:59 UTC

This particular problem IS fixed.. as proof, there is a testcase (test15228 in
TestBugs.java), that failed prior to the fix, and works now (2.0pre3). 

So your problem is different.. and we will we able to help you only if you give
a small test sheet and the minimum code to replicate this. If you have a problem
providing the sheet, try replicating the problem with dummy data. 
Comment 11 Avik Sengupta 2003-10-06 10:06:59 UTC
As I said earlier, this particular bug IS fixed, there is a testcase to prove
it. Clay, if you are still having a problem, please attach an exmaple sheet and
the minimum amount of code reqd to fix the problem.