summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2004-06-26 11:37:28 +0000
committerMark Wielaard <mark@klomp.org>2004-06-26 11:37:28 +0000
commit755c1990e0d5a86bb89deb4f76c6fd2bc55852be (patch)
treef900f7fd57445c168dd574f8a0a547d79ec7f535
parent66528b41a0ba7ada184b4bc0dcc94e9d061813ec (diff)
downloadclasspath-755c1990e0d5a86bb89deb4f76c6fd2bc55852be.tar.gz
2004-06-25 Anthony Green <green@redhat.com>
* java/util/zip/ZipFile.java (getInputStream): Return null if entry not found.
-rw-r--r--ChangeLog5
-rw-r--r--java/util/zip/ZipFile.java14
2 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index bf1b799fb..551744241 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-06-25 Anthony Green <green@redhat.com>
+
+ * java/util/zip/ZipFile.java (getInputStream): Return null if
+ entry not found.
+
2004-06-25 Mark Wielaard <mark@klomp.org>
* java/io/FilePermission.java (usingPerms): Removed.
diff --git a/java/util/zip/ZipFile.java b/java/util/zip/ZipFile.java
index 50f489fdb..25b578543 100644
--- a/java/util/zip/ZipFile.java
+++ b/java/util/zip/ZipFile.java
@@ -408,8 +408,18 @@ public class ZipFile implements ZipConstants
* 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 @@ public class ZipFile implements ZipConstants
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();