commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Hartford" <>
Subject RE: [VFS] FileContentInputStream
Date Wed, 13 Apr 2005 15:26:56 GMT
Hi Mario,
I was hoping the example would demonstrate the problem:

public InputStream returnStream(FileObject myfile) throws Exception{
	FileContent fc = FileObject.getFileContent();
	InputStream result = fc.getInputStream();
	Return result; 

Public void doSomething(FileObject myfile){
	InputStream is = returnStream(myfile);
	//do something with is 
====end example====

In the 'doSomething' method, you call the returnStream method that uses
FileContent object and return InputStream.

Only problem is that FileContent is only within the scope of
returnStream, which means that the InputStream returned by it to
doSomething() no longer has an active FileContent object (i.e.
FileContent was closed when it leaves the scope of returnStream()).

So, doSomething() has a non-functioning InputStream to work with.  This
means you are required to pass around the FileContent object, and have
no means to pass a generic InputStream.

Just something to think about,

> -----Original Message-----
> From: Mario Ivankovits [] 
> Sent: Wednesday, April 13, 2005 2:37 AM
> To: Jakarta Commons Users List
> Subject: Re: [VFS] FileContentInputStream
> Hello Darren!
> >public InputStream returnStream(FileObject myfile) throws Exception{ 
> >FileContent fc = FileObject.getFileContent(); InputStream result = 
> >fc.getInputStream(); Return result; }
> >
> >Public void doSomething(FileObject myfile){ InputStream is = 
> >returnStream(myfile); //do something with is }
> >
> >This method results in non-working code because as soon as you leave 
> >the method (or you call fc.close()) the FileContent object 
> and related 
> >FileContentInputStream innerclass disappears and the InputStream 
> >becomes nothing.  Before reporting this as a bug, wondering 
> if anyone 
> >else has any thoughts on this?
> >  
> >
> Sorry, I dont get it.
> What do you mean by "disappears" and "becomes nothing"?
> *) If you close the filecontent, all streams created by the 
> current thread will be closed.
> *) If you close the inputStream only this stream will be 
> closed and detached from the current thread
> Do you get any exception?
> What "scheme" do you have a problem with?
> ---
> Mario

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message