Patch: ZipFile.getInputStream shouldn't throw NoSuchElement.

Anthony Green green@redhat.com
Wed Jun 9 17:18:00 GMT 2004


On Tue, 2004-06-08 at 23:08, David Holmes wrote:
> Anthony Green wrote:
> > ZipFile.getInputStream shouldn't be throwing NoSuchElement exceptions.
> > It should be returning null instead.
> 
> Neither behaviour is specified for this method, though it would be
> compatible with Sun's implementation to return null.
> 
> If the ZipEntry is not for an entry in the current zip file you could also
> throw an IOException - specifically FileNotFoundException. That would seem
> more correct to me. Or even just a ZipException - also correct.
> 
> Returning null seems incorrect.

I think that throwing NoSuchElement is clearly wrong from the
NoSuchElement documentation, and would be surprising given the
getInputStream documentation.  FileNotFoundException would also be a
surprising result, and wrong since we're not opening a file (as per the
FileNotFoundException documentation). ZipException is reserved for ZIP
format errors.

Applications are depending on this behaviour, and it's an intuitive
enough result that I think we should just make this change.

AG

-- 
Anthony Green <green@redhat.com>
Red Hat, Inc.



More information about the Java-patches mailing list