No need to wrap OpenXML4JRuntimeException in another instance of itself and fix some compilation/javadoc warnings

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1730482 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-02-15 10:08:26 +00:00
parent 16b90ce342
commit d1d31485a1
1 changed files with 9 additions and 10 deletions

View File

@ -69,7 +69,9 @@ public final class ZipPackage extends Package {
try { try {
this.contentTypeManager = new ZipContentTypeManager(null, this); this.contentTypeManager = new ZipContentTypeManager(null, this);
} catch (InvalidFormatException e) {} } catch (InvalidFormatException e) {
logger.log(POILogger.WARN,"Could not parse ZipPackage", e);
}
} }
/** /**
@ -98,13 +100,11 @@ public final class ZipPackage extends Package {
* The path of the file to open or create. * The path of the file to open or create.
* @param access * @param access
* The package access mode. * The package access mode.
* @throws InvalidFormatException
* If the content type part parsing encounters an error.
*/ */
ZipPackage(String path, PackageAccess access) { ZipPackage(String path, PackageAccess access) {
super(access); super(access);
ZipFile zipFile = null; final ZipFile zipFile;
try { try {
zipFile = ZipHelper.openZipFile(path); zipFile = ZipHelper.openZipFile(path);
@ -123,13 +123,11 @@ public final class ZipPackage extends Package {
* The file to open or create. * The file to open or create.
* @param access * @param access
* The package access mode. * The package access mode.
* @throws InvalidFormatException
* If the content type part parsing encounters an error.
*/ */
ZipPackage(File file, PackageAccess access) { ZipPackage(File file, PackageAccess access) {
super(access); super(access);
ZipFile zipFile = null; final ZipFile zipFile;
try { try {
zipFile = ZipHelper.openZipFile(file); zipFile = ZipHelper.openZipFile(file);
@ -150,8 +148,6 @@ public final class ZipPackage extends Package {
* Zip data to load. * Zip data to load.
* @param access * @param access
* The package access mode. * The package access mode.
* @throws InvalidFormatException
* If the content type part parsing encounters an error.
*/ */
ZipPackage(ZipEntrySource zipEntry, PackageAccess access) { ZipPackage(ZipEntrySource zipEntry, PackageAccess access) {
super(access); super(access);
@ -428,8 +424,8 @@ public final class ZipPackage extends Package {
public void saveImpl(OutputStream outputStream) { public void saveImpl(OutputStream outputStream) {
// Check that the document was open in write mode // Check that the document was open in write mode
throwExceptionIfReadOnly(); throwExceptionIfReadOnly();
ZipOutputStream zos = null;
final ZipOutputStream zos;
try { try {
if (!(outputStream instanceof ZipOutputStream)) if (!(outputStream instanceof ZipOutputStream))
zos = new ZipOutputStream(outputStream); zos = new ZipOutputStream(outputStream);
@ -499,6 +495,9 @@ public final class ZipPackage extends Package {
} }
} }
zos.close(); zos.close();
} catch (OpenXML4JRuntimeException e) {
// no need to wrap this type of Exception
throw e;
} catch (Exception e) { } catch (Exception e) {
throw new OpenXML4JRuntimeException( throw new OpenXML4JRuntimeException(
"Fail to save: an error occurs while saving the package : " "Fail to save: an error occurs while saving the package : "