This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]