commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch: ZipFile.getInputStream shouldn't throw NoSuchElement.


From: Mark Wielaard
Subject: Re: Patch: ZipFile.getInputStream shouldn't throw NoSuchElement.
Date: Sat, 26 Jun 2004 13:36:57 +0200

Hi,

On Fri, 2004-06-25 at 18:03, Anthony Green wrote:
> > So lets go for what Anthony proposes. Return null and document it.
> 
> I've already checked a patch into libgcj with this comment:

OK. Also checked into GNU Classpath CVS now as:

2004-06-25  Anthony Green  <address@hidden>

       * java/util/zip/ZipFile.java (getInputStream): Return null if
       entry not found.

Thanks,

Mark

--- java/util/zip/ZipFile.java  25 Nov 2003 22:29:52 -0000      1.15
+++ java/util/zip/ZipFile.java  26 Jun 2004 11:34:06 -0000
@@ -408,8 +408,18 @@
    * uncompressed data.  Normally zip entry should be an entry
    * returned by getEntry() or entries().
    *
+   * This implementation returns null if the requested entry does not
+   * exist.  This decision is not obviously correct, however, it does
+   * appear to mirror Sun's implementation, and it is consistant with
+   * their javadoc.  On the other hand, the old JCL book, 2nd Edition,
+   * claims that this should return a "non-null ZIP entry".  We have
+   * chosen for now ignore the old book, as modern versions of Ant (an
+   * important application) depend on this behaviour.  See discussion
+   * in this thread:
+   * http://gcc.gnu.org/ml/java-patches/2004-q2/msg00602.html
+   *
    * @param entry the entry to create an InputStream for.
-   * @return the input stream.
+   * @return the input stream, or null if the requested entry does not exist.
    *
    * @exception IOException if a i/o error occured.
    * @exception ZipException if the Zip archive is malformed.
@@ -420,7 +430,7 @@
     String name = entry.getName();
     ZipEntry zipEntry = (ZipEntry) entries.get(name);
     if (zipEntry == null)
-      throw new NoSuchElementException(name);
+      return null;

     long start = checkLocalHeader(zipEntry);
     int method = zipEntry.getMethod();

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]