try to fix tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2024-07-02 00:02:47 +00:00
parent 648a2e58b0
commit a12c95990b
2 changed files with 7 additions and 4 deletions

View File

@ -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();

View File

@ -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();
}