• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in Andrew's Denny DVD - CleanExit.java?  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone:
I think there is a mistake in Andrew's DVD example. Inside the book, it uses 'CleanExit.java' to handle the server shut down. When the user shut down the server, 'CleanExit' will called by the JVM and do some clean up.

Code:
/**
* This method will be executed by the JVM when the application is shutdown.
* It ensures that the database is in a clean state for shutdown (that is,
* there are no outstanding writes occuring).
*/
public void run() {
log.info("Ensuring a clean shutdown");
try {
DvdDatabase database = new DvdDatabase(dbLocation);
database.setDatabaseLocked(true);
} catch (IOException e) {
log.log(Level.SEVERE, "Failed to lock database before exiting", e);
}
}

I assume this is wrong. Because it creates a new database and locks the new database. The real database which has been used by the clients has not been locked for clean up.

Could anyone address please!

Thank you very much!
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only one database can get lock.
 
To do a great right, do a little wrong - shakepeare. twisted little ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!