Bug 53482 - NPE in ODocumentInputStream.readUShort() when parsing XLS
Summary: NPE in ODocumentInputStream.readUShort() when parsing XLS
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.9-dev
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-06-28 18:09 UTC by tjuchniewicz
Modified: 2012-06-30 13:22 UTC (History)
0 users

Example XLS file. (12.50 KB, application/vnd.ms-excel)
2012-06-28 18:09 UTC, tjuchniewicz

Note You need to log in before you can comment on or make changes to this bug.
Description tjuchniewicz 2012-06-28 18:09:00 UTC
Created attachment 29005 [details]
Example XLS file.


Caused by: java.lang.NullPointerException
	at org.apache.poi.poifs.filesystem.ODocumentInputStream.readUShort(ODocumentInputStream.java:294)
	at org.apache.poi.poifs.filesystem.DocumentInputStream.readUShort(DocumentInputStream.java:163)
	at org.apache.poi.hssf.record.RecordInputStream$SimpleHeaderInput.readRecordSID(RecordInputStream.java:98)
	at org.apache.poi.hssf.record.RecordInputStream.readNextSid(RecordInputStream.java:177)
	at org.apache.poi.hssf.record.RecordInputStream.<init>(RecordInputStream.java:115)
	at org.apache.poi.hssf.record.RecordInputStream.<init>(RecordInputStream.java:103)
	at org.apache.poi.hssf.record.RecordFactoryInputStream.<init>(RecordFactoryInputStream.java:180)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:440)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:285)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:248)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:192)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:327)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:308)
	at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:70)

When file form attachment is re-saved in MS Office or OpenOffice then POI parse XLS with no NPE.
Comment 1 Nick Burch 2012-06-28 18:53:04 UTC
Does opening the file with NPOIFSFileSystem rather than the older POIFSFileSystem solve the problem for you?
Comment 2 tjuchniewicz 2012-06-29 06:55:42 UTC
Yes. After switching to NPOIFSFileSystem it works fine. My problem is solved, thanks.
Comment 3 Nick Burch 2012-06-30 13:22:54 UTC
There are a couple of design snags in the older POIFS implementation, which is partly why we re-wrote it (those and cleaner code now the documentation is better + public, lower memory footprint etc). I think this bug is likely related to one of the gnarly bits in the old codebase, so I'm marking this as Won't Fix since it's corrected by the new implementation