We decided to create this new bug, although we found bug 31114 and bug 33082 which describe similar problems. On execution of the following code snippet: POIFSFileSystem fs = new POIFSFileSystem(request.getServletContext ().getResourceAsStream("WEB-INF/workbook.xls")); HSSFWorkbook wb = new HSSFWorkbook (fs); ... we get an InvocationTargetException for the createRecord method-call (else block: retval = new UnknownRecord(rectype, size, data);) in class org.apache.poi.hssf.record.RecordFactory. On analysing this call, we found an IndexOutOfBoundsException. The Exception is thrown on execution of System.arraycopy(). While remote-debugging this scenario: Starting at constructor call till execution of the arraycopy statement, there was nothing abnormal. But on execution of the arraycopy statement, we found the following: public static void arraycopy( byte[] src, int src_position, byte[] dst, int dst_position, int length) - The parameter length did'nt match the available size of parameter src. By patching the parameter length to: length=Math.min (length, Math.min(src.length-src_position, dst.length-dst_position)); - we were able to load the workbook. We don't know why in this case these parameters are inconsitent to each other, but we want to request for help. In the attachment you'll find our patching class as an proposal solution. thx for your help!
Created attachment 14455 [details] POI 2.0 patched origin src Added SystemArrayCopyHelper.arraycopy(thedata, 0, data, 4 + offset, thedata.length);
Created attachment 14456 [details] Proposal Solution SystemArrayCopyHelper Helper manipulation copy length for arraycopy call.
Could you possible attach the files that originally caused your problem. This change may have global effects, so I want some testcases before I check this in.
bug 31114 & bug 33082 are now fixed. Only reading what is left of a record is a bad thing, usually means that our implementation is wrong and you dont want to hide these types of bugs because they will never get fixed. Given that the referenced bug are fixed, and that there is no attached file to try, i am going to close this bug. Jason