Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Why does IFile.setContents, IFile.create and so on close stream?
Why does IFile.setContents, IFile.create and so on close stream? [message #516079] Mon, 22 February 2010 12:25 Go to next message
Mickael Istria is currently offline Mickael Istria
Messages: 735
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi,

I just faced an annoying behavior (from my point of view) with IFile, and I think there are probably arguments to explain it that I'd love to understand.
As described in title IFile.setContents, IFile.create & co close the InputStream we give to it. AFAIK, a good practice is to let the creator of the stream close it. This is particularly annoying when manipulating a ZipInputStream, that gets closed although there are some remaining entries into it.

Thanks to anyone who could give me insight about this behavior ;)

--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: Why does IFile.setContents, IFile.create and so on close stream? [message #516143 is a reply to message #516079] Mon, 22 February 2010 15:08 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25918
Registered: July 2009
Senior Member
Mickael,

Comments below.

Mickael Istria wrote:
> Hi,
>
> I just faced an annoying behavior (from my point of view) with IFile,
> and I think there are probably arguments to explain it that I'd love
> to understand.
> As described in title IFile.setContents, IFile.create & co close the
> InputStream we give to it. AFAIK, a good practice is to let the
> creator of the stream close it. This is particularly annoying when
> manipulating a ZipInputStream, that gets closed although there are
> some remaining entries into it.
This is probably the only time it's annoying given that the input stream
will have been fully consumed to populate the resource. So generally,
closing the stream is the only useful thing left to do. It's clear that
it would be impossible to change this behavior now, so best live with
it. Perhaps use a FilterInputStream that overrides close to do
something else.
>
> Thanks to anyone who could give me insight about this behavior ;)
>
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php
Previous Topic:"Problems" view/tab does not show any entries for a Java project
Next Topic:Eclipse 3.5 AIX - Failed to retrieve default libraries for /TOOLBOX/aix/JDK/jdk1.6.0_00
Goto Forum:
  


Current Time: Thu Jul 24 23:59:08 EDT 2014

Powered by FUDForum. Page generated in 0.01526 seconds