Bug 64274 - ExtractorFactory#createExtractor shall throw POIXMLException
Summary: ExtractorFactory#createExtractor shall throw POIXMLException
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 4.1.x-dev
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-28 01:03 UTC by zhonghao
Modified: 2020-05-14 16:21 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhonghao 2020-03-28 01:03:50 UTC
When OOXML file is invalid, org.apache.poi.ooxml.extractor.ExtractorFactory#createExtractor throws IllegalArgumentException:

 public static POITextExtractor createExtractor(OPCPackage pkg) throws IOException, OpenXML4JException, XmlException {
   ...
 if (core.size() != 1) {
      throw new IllegalArgumentException("Invalid OOXML Package received - expected 1 core document, found " + core.size());
            }
 }

POI already implements POIXMLException for this type of problem. Other methods all throw this exception:

org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart#getPartFromOPCPackage

org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart#getPartFromOPCPackage

org.apache.poi.xssf.eventusermodel.XSSFReader#XSSFReader

Please update the exception of createExtractor, so it is easier to catch this type of problems.