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
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.
Do we have any small files in the regression corpus that show the same bug?
We don't. I can manually minify the file...
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
r1880834 manually created a small example from the original