• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Close() method

 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In the FBN's Data class, there is a claose method as follows:
How this method can flush any outstanding writes at the same time?
/**
* This method closes the database, flushing any outstanding
* writes at the same time. Any attempt to access the
* database after this results in a IOException.
*/
public synchronized void close() {
try {
db.close();
} catch (IOException e) {}
db = null;
}
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How this method can flush any outstanding writes at the same time?
Perhaps that's handled by
db.close();
Have you looked at the code for the db class?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, I can see three possibilities here:
  • this is wishful thinking on the part of the author,
  • or the author was considering a future implementation where cacheing may occur and making sure that whoever makes such a modification is aware that they will need to do any write's back to file
  • or the author is thinking of a JVM that caches the system I/O at a lower level and does a final flush and write when the file is closed


  • Since db is just an instance of RandomAccessFile, I don't see any explicit flush of data prior to the close.
    Regards, Andrew
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic