In java driver, I saw it has not close the OutputStream before return, here is the code(GridFSDBFile.java, line 66, version 2.7.2):
public long writeTo( File f ) throws IOException { return writeTo( new FileOutputStream( f ) ); }
/** * Writes the file's data to an OutputStream * @param out the OutputStream * @return * @throws IOException */ public long writeTo( OutputStream out ) throws IOException { final int nc = numChunks(); for ( int i=0; i<nc; i++ ){ out.write( getChunk( i ) ); } return _length;* // is need to close out before return ? or the ** destructor function will close it?* }
On Wed, Sep 5, 2012 at 9:58 PM, gen liu <tomliu...@gmail.com> wrote:
> In java driver, I saw it has not close the OutputStream before return, here
> is the code(GridFSDBFile.java, line 66, version 2.7.2):
> public long writeTo( File f ) throws IOException {
> return writeTo( new FileOutputStream( f ) );
> }
> /**
> * Writes the file's data to an OutputStream
> * @param out the OutputStream
> * @return
> * @throws IOException
> */
> public long writeTo( OutputStream out )
> throws IOException {
> final int nc = numChunks();
> for ( int i=0; i<nc; i++ ){
> out.write( getChunk( i ) );
> }
> return _length; // is need to close out before return ? or the
> destructor function will close it?
> }
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
> The garbage collector will clean it up, but it is better to do it > sooner than later on high volume servers.
> On Wed, Sep 5, 2012 at 9:58 PM, gen liu <toml...@gmail.com <javascript:>> > wrote: > > In java driver, I saw it has not close the OutputStream before return, > here > > is the code(GridFSDBFile.java, line 66, version 2.7.2):
> > public long writeTo( File f ) throws IOException { > > return writeTo( new FileOutputStream( f ) ); > > }
> > /** > > * Writes the file's data to an OutputStream > > * @param out the OutputStream > > * @return > > * @throws IOException > > */ > > public long writeTo( OutputStream out ) > > throws IOException { > > final int nc = numChunks(); > > for ( int i=0; i<nc; i++ ){ > > out.write( getChunk( i ) ); > > } > > return _length; // is need to close out before return ? or the > > destructor function will close it? > > }
> > -- > > You received this message because you are subscribed to the Google > > Groups "mongodb-user" group. > > To post to this group, send email to mongod...@googlegroups.com<javascript:> > > To unsubscribe from this group, send email to > > mongodb-user...@googlegroups.com <javascript:> > > See also the IRC channel -- freenode.net#mongodb
> The garbage collector will clean it up, but it is better to do it > sooner than later on high volume servers.
> On Wed, Sep 5, 2012 at 9:58 PM, gen liu <toml...@gmail.com <javascript:>> > wrote: > > In java driver, I saw it has not close the OutputStream before return, > here > > is the code(GridFSDBFile.java, line 66, version 2.7.2):
> > public long writeTo( File f ) throws IOException { > > return writeTo( new FileOutputStream( f ) ); > > }
> > /** > > * Writes the file's data to an OutputStream > > * @param out the OutputStream > > * @return > > * @throws IOException > > */ > > public long writeTo( OutputStream out ) > > throws IOException { > > final int nc = numChunks(); > > for ( int i=0; i<nc; i++ ){ > > out.write( getChunk( i ) ); > > } > > return _length; // is need to close out before return ? or the > > destructor function will close it? > > }
> > -- > > You received this message because you are subscribed to the Google > > Groups "mongodb-user" group. > > To post to this group, send email to mongod...@googlegroups.com<javascript:> > > To unsubscribe from this group, send email to > > mongodb-user...@googlegroups.com <javascript:> > > See also the IRC channel -- freenode.net#mongodb