You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Darren Hartford <dh...@ghsinc.com> on 2005/04/12 16:00:30 UTC

[VFS] FileContentInputStream

Hey all,
Interesting...concern.  I'm not sure if it is an issue as it seems
designed this way, but at least give a scenario where it breaks.

Under the DefaultFileContent class and related subclasses is an
innerclass called 'FileContentInputStream'.  Now for the example:

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?

Thanks,
-D


Re: [VFS] FileContentInputStream

Posted by Mario Ivankovits <ma...@ops.co.at>.
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org