aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-10-10 09:58:02 +0000
committerPJ Fanning <fanningpj@apache.org>2021-10-10 09:58:02 +0000
commit2514e4d0ab925a4de8baa4ed4bcdbb90ca2713ab (patch)
treef7fdf0803511a51f89ec8672dad6c2e26a5b3347 /poi
parent69b2f313741845d42f8a756db83cc5a9fbd4b8a9 (diff)
downloadpoi-2514e4d0ab925a4de8baa4ed4bcdbb90ca2713ab.tar.gz
poi-2514e4d0ab925a4de8baa4ed4bcdbb90ca2713ab.zip
[bug-65452] fix issue where WorkbookFactory.create(File, ...) returns null if file type not recognised
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894097 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/WorkbookFactory.java10
1 files changed, 3 insertions, 7 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/poi/src/main/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
index 0b910f379f..823bbf5c4e 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
@@ -19,11 +19,7 @@ package org.apache.poi.ss.usermodel;
import static org.apache.poi.extractor.ExtractorFactory.OOXML_PACKAGE;
import static org.apache.poi.poifs.crypt.Decryptor.DEFAULT_POIFS_ENTRY;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
@@ -291,9 +287,9 @@ public final class WorkbookFactory {
ooxmlEnc = root.hasEntry(DEFAULT_POIFS_ENTRY) || root.hasEntry(OOXML_PACKAGE);
}
return wp(ooxmlEnc ? FileMagic.OOXML : fm, w -> w.create(file, password, readOnly));
+ } else {
+ throw new IOException("Can't open workbook - unsupported file type: "+fm);
}
-
- return null;
}