Bug 53482

Summary: NPE in ODocumentInputStream.readUShort() when parsing XLS
Product: POI Reporter: tjuchniewicz <tjuchniewicz>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WONTFIX    
Severity: major    
Priority: P2    
Version: 3.9-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Example XLS file.

Description tjuchniewicz 2012-06-28 18:09:00 UTC
Created attachment 29005 [details]
Example XLS file.

Stacktrace:

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