diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-11-08 20:49:45 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-11-08 20:49:45 +0000 |
commit | 2a6ef7e4aef66c996ded2704b2323436a311dd11 (patch) | |
tree | d419d154c350aa60adf07a914c5b91602a9101ea /poi-ooxml | |
parent | 7739885b2fc3bd978998a9a30857a8ad3d0ac549 (diff) | |
download | poi-2a6ef7e4aef66c996ded2704b2323436a311dd11.tar.gz poi-2a6ef7e4aef66c996ded2704b2323436a311dd11.zip |
throw IOException if getInputStream fails
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894848 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java | 12 | ||||
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java index 2a32f8b5a7..5cfa893099 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java @@ -71,27 +71,27 @@ import org.apache.poi.util.TempFile; /** * Returns zip entry. * @return input stream - * @throws RuntimeException since POI 5.1.0, - * a RuntimeException can occur if the optional temp file has been removed + * @throws IOException since POI 5.2.0, + * an IOException can occur if the optional temp file has been removed (was a RuntimeException in POI 5.1.0) * @see ZipInputStreamZipEntrySource#setThresholdBytesForTempFiles(int) */ - public InputStream getInputStream() { + public InputStream getInputStream() throws IOException { if (encryptedTempData != null) { try { return encryptedTempData.getInputStream(); } catch (IOException e) { - throw new RuntimeException("failed to read from encrypted temp data", e); + throw new IOException("failed to read from encrypted temp data", e); } } else if (tempFile != null) { try { return new FileInputStream(tempFile); } catch (FileNotFoundException e) { - throw new RuntimeException("temp file " + tempFile.getAbsolutePath() + " is missing"); + throw new IOException("temp file " + tempFile.getAbsolutePath() + " is missing"); } } else if (data != null) { return new UnsynchronizedByteArrayInputStream(data); } else { - throw new RuntimeException("Cannot retrieve data from Zip Entry, probably because the Zip Entry was closed before the data was requested."); + throw new IOException("Cannot retrieve data from Zip Entry, probably because the Zip Entry was closed before the data was requested."); } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java index ad99adb693..f47418e721 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipInputStreamZipEntrySource.java @@ -107,7 +107,7 @@ public class ZipInputStreamZipEntrySource implements ZipEntrySource { } @Override - public InputStream getInputStream(ZipArchiveEntry zipEntry) { + public InputStream getInputStream(ZipArchiveEntry zipEntry) throws IOException { assert (zipEntry instanceof ZipArchiveFakeEntry); return ((ZipArchiveFakeEntry)zipEntry).getInputStream(); } |