This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
RE: Patch: ZipFile.getInputStream shouldn't throw NoSuchElement.
- From: Anthony Green <green at redhat dot com>
- To: David Holmes <dholmes at dltech dot com dot au>
- Cc: classpath at gnu dot org, java-patches at gcc dot gnu dot org
- Date: Wed, 09 Jun 2004 07:25:50 -0700
- Subject: RE: Patch: ZipFile.getInputStream shouldn't throw NoSuchElement.
- Organization: Red Hat, Inc.
- References: <NFBBKALFDCPFIDBNKAPCAEBCEEAA.dholmes@dltech.com.au>
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.