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: Anthony Green
Subject: RE: Patch: ZipFile.getInputStream shouldn't throw NoSuchElement.
Date: Wed, 09 Jun 2004 07:25:50 -0700

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 <address@hidden>
Red Hat, Inc.





reply via email to

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