Bug 64667 - NPE in loading the StylesTable
Summary: NPE in loading the StylesTable
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-13 14:38 UTC by Tim Allison
Modified: 2020-08-13 18:22 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Allison 2020-08-13 14:38:16 UTC
A Tika user reported an NPE when loading the StylesTable and shared a triggering file[1].

I confirmed this NPE in trunk just now.

java.lang.NullPointerException
	at org.apache.poi.xssf.usermodel.XSSFTableStyle.<init>(XSSFTableStyle.java:64)
	at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:245)
	at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:138)
	at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:61)
	at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:659)
	at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:165)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:288)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:309)
	at org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook(XSSFTestDataSamples.java:60)
	at org.apache.poi.xssf.extractor.TestXSSFExcelExtractor.getExtractor(TestXSSFExcelExtractor.java:45)




[1] https://issues.apache.org/jira/browse/TIKA-3163
Comment 1 Tim Allison 2020-08-13 14:43:43 UTC
Adding a null check fixes the problem on the offending file:

StylesTable.java:242
            if (ctTableStyles != null && styleDxfs != null) {

I'll wait for a clean build and then commit unless there are objections.

My preference is not to add the triggering file to our unit tests because its size outweighs the scope of the problem/fix.

I can add a unit test with the file if desired.
Comment 2 Nick Burch 2020-08-13 15:29:13 UTC
Do we have any small files in the regression corpus that show the same bug?
Comment 3 Tim Allison 2020-08-13 16:51:51 UTC
We don't.  I can manually minify the file...
Comment 4 Tim Allison 2020-08-13 16:54:18 UTC
For anyone curious about searching stacktraces...our db is now live via Datasette

https://corpora.tika.apache.org/datasette/corpora-metadata?sql=select%0D%0A++ID%2C%0D%0A++ORIG_STACK_TRACE%2C%0D%0A++SORT_STACK_TRACE%2C%0D%0A++PARSE_EXCEPTION_ID%0D%0Afrom%0D%0A++PARSE_EXCEPTIONS%0D%0Awhere%0D%0A++orig_stack_trace+like+%27%25XSSFTableStyle%25%27%0D%0Aorder+by%0D%0A++ID%0D%0Alimit%0D%0A++101


select
  ID,
  ORIG_STACK_TRACE,
  SORT_STACK_TRACE,
  PARSE_EXCEPTION_ID
from
  PARSE_EXCEPTIONS
where
  orig_stack_trace like '%XSSFTableStyle%'
order by
  ID
limit
  101
Comment 5 Tim Allison 2020-08-13 18:22:08 UTC
r1880834

manually created a small example from the original