Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E067C200B80 for ; Wed, 14 Sep 2016 15:28:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DF071160ABA; Wed, 14 Sep 2016 13:28:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3208B160AB4 for ; Wed, 14 Sep 2016 15:28:35 +0200 (CEST) Received: (qmail 96004 invoked by uid 500); 14 Sep 2016 13:28:34 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 95995 invoked by uid 99); 14 Sep 2016 13:28:34 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Sep 2016 13:28:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 0ED47C05C3 for ; Wed, 14 Sep 2016 13:28:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.426 X-Spam-Level: X-Spam-Status: No, score=-0.426 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id SIRtLBufuLKd for ; Wed, 14 Sep 2016 13:28:29 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTP id 80EB75F246 for ; Wed, 14 Sep 2016 13:28:29 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D765CE0115 for ; Wed, 14 Sep 2016 13:28:28 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 91FA63A031D for ; Wed, 14 Sep 2016 13:28:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1760708 - /poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java Date: Wed, 14 Sep 2016 13:28:28 -0000 To: commits@poi.apache.org From: onealj@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160914132828.91FA63A031D@svn01-us-west.apache.org> archived-at: Wed, 14 Sep 2016 13:28:36 -0000 Author: onealj Date: Wed Sep 14 13:28:27 2016 New Revision: 1760708 URL: http://svn.apache.org/viewvc?rev=1760708&view=rev Log: give more helpful exceptions rather than returning null when zip file cannot be opened Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java?rev=1760708&r1=1760707&r2=1760708&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java Wed Sep 14 13:28:27 2016 @@ -19,6 +19,7 @@ package org.apache.poi.openxml4j.opc.int import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PushbackInputStream; @@ -239,10 +240,15 @@ public final class ZipHelper { * @param file * The file to open. * @return The zip archive freshly open. + * @throws IOException if the zip file cannot be opened or closed to read the header signature + * @throws NotOfficeXmlFileException if stream does not start with zip header signature */ - public static ZipFile openZipFile(File file) throws IOException { + public static ZipFile openZipFile(File file) throws IOException, NotOfficeXmlFileException { if (!file.exists()) { - return null; + throw new FileNotFoundException("File does not exist"); + } + if (file.isDirectory()) { + throw new IOException("File is a directory"); } // Peek at the first few bytes to sanity check --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org