]> source.dussan.org Git - poi.git/commitdiff
No need to wrap OpenXML4JRuntimeException in another instance of itself and fix some...
authorDominik Stadler <centic@apache.org>
Mon, 15 Feb 2016 10:08:26 +0000 (10:08 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 15 Feb 2016 10:08:26 +0000 (10:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1730482 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java

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