aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2024-07-02 00:02:47 +0000
committerPJ Fanning <fanningpj@apache.org>2024-07-02 00:02:47 +0000
commita12c95990b3e89158637339a62f8f617a4d91742 (patch)
treea9d9351a3a596005bd11b278a00ffb89509ac6c2 /poi-ooxml/src
parent648a2e58b079840f42dfc2ed521b7695d4d196d4 (diff)
downloadpoi-a12c95990b3e89158637339a62f8f617a4d91742.tar.gz
poi-a12c95990b3e89158637339a62f8f617a4d91742.zip
try to fix tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918808 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/ooxml/util/PackageHelper.java8
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java3
2 files changed, 7 insertions, 4 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/PackageHelper.java b/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/PackageHelper.java
index 119289cfd4..a7b7f8c1e5 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/PackageHelper.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/PackageHelper.java
@@ -48,6 +48,7 @@ public final class PackageHelper {
* @param stream The InputStream to read from - which is closed when it is read
* @return OPCPackage
* @throws IOException If reading data from the stream fails
+ * @throws POIXMLException If the stream is not a valid OPC package
*/
public static OPCPackage open(InputStream stream) throws IOException {
return open(stream, true);
@@ -58,6 +59,7 @@ public final class PackageHelper {
* @param closeStream whether to close the stream
* @return OPCPackage
* @throws IOException If reading data from the stream fails
+ * @throws POIXMLException If the stream is not a valid OPC package
* @since POI 5.2.0
*/
public static OPCPackage open(InputStream stream, boolean closeStream) throws IOException {
@@ -65,10 +67,10 @@ public final class PackageHelper {
return OPCPackage.open(stream, closeStream);
} catch (InvalidFormatException e) {
final Throwable cause = e.getCause();
- if (cause instanceof IOException) {
- throw (IOException) cause;
+ if (cause instanceof InvalidZipException) {
+ throw (InvalidZipException) cause;
}
- throw new IOException(e);
+ throw new POIXMLException(e);
} finally {
if (closeStream) {
stream.close();
diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
index 0b476b1b12..d43ccef578 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
@@ -326,7 +326,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
pack = new ZipPackage(in, PackageAccess.READ_WRITE);
} catch (InvalidZipException e) {
throw new InvalidFormatException(e.getMessage(), e);
- } try {
+ }
+ try {
if (pack.partList == null) {
pack.getParts();
}