mirror of https://github.com/apache/poi.git
throw IOException if getInputStream fails
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7739885b2f
commit
2a6ef7e4ae
|
@ -71,27 +71,27 @@ import org.apache.poi.util.TempFile;
|
||||||
/**
|
/**
|
||||||
* Returns zip entry.
|
* Returns zip entry.
|
||||||
* @return input stream
|
* @return input stream
|
||||||
* @throws RuntimeException since POI 5.1.0,
|
* @throws IOException since POI 5.2.0,
|
||||||
* a RuntimeException can occur if the optional temp file has been removed
|
* an IOException can occur if the optional temp file has been removed (was a RuntimeException in POI 5.1.0)
|
||||||
* @see ZipInputStreamZipEntrySource#setThresholdBytesForTempFiles(int)
|
* @see ZipInputStreamZipEntrySource#setThresholdBytesForTempFiles(int)
|
||||||
*/
|
*/
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() throws IOException {
|
||||||
if (encryptedTempData != null) {
|
if (encryptedTempData != null) {
|
||||||
try {
|
try {
|
||||||
return encryptedTempData.getInputStream();
|
return encryptedTempData.getInputStream();
|
||||||
} catch (IOException e) {
|
} 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) {
|
} else if (tempFile != null) {
|
||||||
try {
|
try {
|
||||||
return new FileInputStream(tempFile);
|
return new FileInputStream(tempFile);
|
||||||
} catch (FileNotFoundException e) {
|
} 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) {
|
} else if (data != null) {
|
||||||
return new UnsynchronizedByteArrayInputStream(data);
|
return new UnsynchronizedByteArrayInputStream(data);
|
||||||
} else {
|
} 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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class ZipInputStreamZipEntrySource implements ZipEntrySource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStream(ZipArchiveEntry zipEntry) {
|
public InputStream getInputStream(ZipArchiveEntry zipEntry) throws IOException {
|
||||||
assert (zipEntry instanceof ZipArchiveFakeEntry);
|
assert (zipEntry instanceof ZipArchiveFakeEntry);
|
||||||
return ((ZipArchiveFakeEntry)zipEntry).getInputStream();
|
return ((ZipArchiveFakeEntry)zipEntry).getInputStream();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue