Need to close OutputStream when write file in GridFSDBFile.java(java driver, version 2.7.2)
318 views
Skip to first unread message
gen liu
unread,
Sep 5, 2012, 9:58:36 PM9/5/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongod...@googlegroups.com
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? }
Scott Hernandez
unread,
Sep 5, 2012, 10:24:48 PM9/5/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message