https://bz.apache.org/bugzilla/show_bug.cgi?id=69557
Bug ID: 69557 Summary: WorkbookFactory fails to create a workbook from file Product: POI Version: 5.2.3-FINAL Hardware: PC OS: Linux Status: NEW Severity: critical Priority: P2 Component: XSSF Assignee: dev@poi.apache.org Reporter: gaguilardelg...@medallia.com Target Milestone: --- While reading files between 11-14Mb Apache POI fails to read it. It seems that the allocation policy is not behaving correctly. The error is: Tried to read data but the maximum length for this record type is 100,000,000. If the file is not corrupt and not large, please open an issue on bugzilla to request increasing the maximum allowable size for this record type. You can set a higher override value with IOUtils.setByteArrayMaxOverride() at org.apache.poi.util.IOUtils.throwRecordTruncationException(IOUtils.java:607) at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:249) at org.apache.poi.util.IOUtils.toByteArrayWithMaxLength(IOUtils.java:220) at org.apache.poi.openxml4j.util.ZipArchiveFakeEntry.<init>(ZipArchiveFakeEntry.java:81) at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:98) at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:132) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:319) at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:97) at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:36) at org.apache.poi.ss.usermodel.WorkbookFactory.lambda$create$2(WorkbookFactory.java:224) at org.apache.poi.ss.usermodel.WorkbookFactory.wp(WorkbookFactory.java:329) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:224) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:185) It seems like a ZipEntry size is not determined so it requests -1 bytes that is converted to the max allocation buffer by this code. Inside ZipArchiveFakeEntry line 81 // Grab the de-compressed contents for later data = (entrySize == -1) ? IOUtils.toByteArrayWithMaxLength(inp, getMaxEntrySize()) : IOUtils.toByteArray(inp, (int)entrySize, getMaxEntrySize()); The problem is that the underlaying library on IOUtils has a max size of 100Mb allocations, so it could not be allocated, and explodes. We can use IOUtils.setByteArrayMaxOverride() to enlarge the buffer by 1 byte, and everything should work. But it also doesn't, triggering new errors. I will link in another case. Expected behavior: The expected behavior is not allocate a buffer big to get the whole chunk in memory but develop an strategy to read in fixed block sizes. So the memory allocated is under constraints. If possible other option is to understand better how the entry size is calculated and make a better assumption. final long entrySize = entry.getSize(); Line 60. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org